Skip to content

Instantly share code, notes, and snippets.

@mavwolverine
Created July 20, 2025 17:58
Show Gist options
  • Save mavwolverine/3a41a1f5a81931ef8a783c032e137c16 to your computer and use it in GitHub Desktop.
Save mavwolverine/3a41a1f5a81931ef8a783c032e137c16 to your computer and use it in GitHub Desktop.
Next.js standalone app server.js hostname setup from env NEXT_HOSTNAME
diff --git a/node_modules/next/dist/build/utils.js b/node_modules/next/dist/build/utils.js
index ce30a5f..24c6f23 100644
--- a/node_modules/next/dist/build/utils.js
+++ b/node_modules/next/dist/build/utils.js
@@ -1487,8 +1487,8 @@ const dir = path.join(__dirname)
process.env.NODE_ENV = 'production'
process.chdir(__dirname)
-const currentPort = parseInt(process.env.PORT, 10) || 3000
-const hostname = process.env.HOSTNAME || '0.0.0.0'
+const currentPort = parseInt(process.env.NEXT_PORT, 10) || 3000
+const hostname = process.env.NEXT_HOSTNAME || '0.0.0.0'
let keepAliveTimeout = parseInt(process.env.KEEP_ALIVE_TIMEOUT, 10)
const nextConfig = ${JSON.stringify(nextConfig)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment