Next.js 13 with custom server (hostname configuration)
Unanswered
Transvaal lion posted this in #help-forum
Transvaal lionOP
I added a custom server.js file as defined here: https://github.com/vercel/next.js/blob/712669f6056a61964760212868494042f55a4445/docs/03-pages/01-building-your-application/06-configuring/10-custom-server.mdx#L24 to the default next app (created with npx create-next-app), and modified the package.json start script as the docs state (NODE_ENV=production node server.js).
The server runs fine with npm run build & npm start when the server.js line that contains the hostname variable has value of 'localhost' (as it is in the template): https://github.com/vercel/next.js/blob/712669f6056a61964760212868494042f55a4445/docs/03-pages/01-building-your-application/06-configuring/10-custom-server.mdx#L29C10-L29C10
However, if I change that value to any other value, I get this error:
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
Error: Call retries were exceeded
at ChildProcessWorker.initialize (/home/user/Projects/nextjs/node_modules/next/dist/compiled/jest-worker/index.js:1:11661)
at ChildProcessWorker._onExit (/home/user/Projects/nextjs/node_modules/next/dist/compiled/jest-worker/index.js:1:12599)
at ChildProcess.emit (node:events:513:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12) {
type: 'WorkerError'
}
Is the hostname value always supposed to be 'localhost'? What about when running Next.js in a production server? I can't change the hostname value to the actual domain name or IP address of my production server since that crash happens. I wonder if this is inteded behaviour or not?
I tried with Next.js 12, and in that the hostname value can be changed.
The server runs fine with npm run build & npm start when the server.js line that contains the hostname variable has value of 'localhost' (as it is in the template): https://github.com/vercel/next.js/blob/712669f6056a61964760212868494042f55a4445/docs/03-pages/01-building-your-application/06-configuring/10-custom-server.mdx#L29C10-L29C10
However, if I change that value to any other value, I get this error:
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
Error: Call retries were exceeded
at ChildProcessWorker.initialize (/home/user/Projects/nextjs/node_modules/next/dist/compiled/jest-worker/index.js:1:11661)
at ChildProcessWorker._onExit (/home/user/Projects/nextjs/node_modules/next/dist/compiled/jest-worker/index.js:1:12599)
at ChildProcess.emit (node:events:513:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12) {
type: 'WorkerError'
}
Is the hostname value always supposed to be 'localhost'? What about when running Next.js in a production server? I can't change the hostname value to the actual domain name or IP address of my production server since that crash happens. I wonder if this is inteded behaviour or not?
I tried with Next.js 12, and in that the hostname value can be changed.