File: //srv/rmgun_admin/admin-next/next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {
// Allow cross-origin requests from Orbstack domains in development
allowedDevOrigins: [
'http://localhost',
'http://localhost:3000',
'http://rmgun-admin-local.orb.local',
'http://nginx.rmgun-admin-local.orb.local',
'http://nextjs-app.rmgun-admin-local.orb.local',
],
// Disable WebSocket for HMR to avoid the 'bind' error
webpack: (config, { isServer }) => {
if (!isServer) {
config.watchOptions = {
...config.watchOptions,
poll: 800,
};
// Exclude server-side modules from client-side bundling
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
crypto: false,
stream: false,
url: false,
zlib: false,
http: false,
https: false,
assert: false,
os: false,
path: false,
};
// Exclude Firebase admin and other server-only packages
config.externals = config.externals || [];
config.externals.push({
"firebase-admin": "firebase-admin",
"firebase-admin/app": "firebase-admin/app",
"firebase-admin/auth": "firebase-admin/auth",
"server-only": "server-only",
});
}
// Allow importing JSON files
config.module.rules.push({
test: /\.json$/,
type: "json",
});
// Handle node: protocol imports
config.resolve.alias = {
...config.resolve.alias,
"node:stream": "stream",
"node:crypto": "crypto",
"node:path": "path",
"node:fs": "fs",
"node:url": "url",
};
return config;
},
// Ensure server-only imports are handled correctly
experimental: {
serverExternalPackages: ["firebase-admin"],
},
// Enable standalone build for Docker
output: 'standalone',
};
export default nextConfig;