Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default server host value causing issues on Windows #27306

Merged
merged 4 commits into from Jul 19, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/next/cli/next-dev.ts
Expand Up @@ -73,12 +73,17 @@ const nextDev: cliCommand = (argv) => {

const port =
args['--port'] || (process.env.PORT && parseInt(process.env.PORT)) || 3000
const host = args['--hostname'] || '0.0.0.0'
const appUrl = `http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`

// We do not set a default host value here to prevent breaking
// some set-ups that rely on listening on other interfaces
const host = args['--hostname']
const appUrl = `http://${
!host || host === '0.0.0.0' ? 'localhost' : host
}:${port}`

startServer({ dir, dev: true, isNextDevCommand: true }, port, host)
.then(async (app) => {
startedDevelopmentServer(appUrl, `${host}:${port}`)
startedDevelopmentServer(appUrl, `${host || '0.0.0.0'}:${port}`)
// Start preflight after server is listening and ignore errors:
preflight().catch(() => {})
// Finalize server bootup:
Expand Down