Skip to content

Commit

Permalink
fix: prefer ipv4 stack for windows, wsl2 and internals
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 30, 2023
1 parent 1ab4c49 commit 2cbe236
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"http-proxy": "^1.18.1",
"httpxy": "^0.1.4",
"jiti": "^1.19.3",
"listhen": "^1.4.3",
"listhen": "^1.4.4",
"magicast": "^0.2.10",
"mlly": "^1.4.1",
"mri": "^1.2.0",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/commands/dev-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default defineCommand({
resolve((server.address() as AddressInfo).port)
})
})
const serverURL = `http://localhost:${port}/`
const serverURL = `http://127.0.0.1:${port}/`
if (!process.send) {
logger.success(`Listening on ${serverURL}`)
}
Expand Down Expand Up @@ -156,7 +156,7 @@ export default defineCommand({
server,
url: listenerInfo.url,
https: false,
address: { host: 'localhost', port },
address: { host: '127.0.0.1', port },
close: () => Promise.reject('Cannot close internal dev server!'),
open: () => Promise.resolve(),
showURL: () => Promise.resolve(),
Expand All @@ -169,8 +169,8 @@ export default defineCommand({

// Sync internal server info to the internals
// It is important for vite-node to use the internal URL
currentNuxt.options.devServer.url = `http://localhost:${port}/`
currentNuxt.options.devServer.host = 'localhost'
currentNuxt.options.devServer.url = `http://127.0.0.1:${port}/`
currentNuxt.options.devServer.host = '127.0.0.1'
currentNuxt.options.devServer.port = port
currentNuxt.options.devServer.https = false

Expand Down
2 changes: 1 addition & 1 deletion src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function _startSubprocess(devServer: DevServer, listener: Listener) {

childProc.on('message', (message: NuxtDevIPCMessage) => {
if (message.type === 'nuxt:internal:dev:ready') {
devServer.setAddress(`http://localhost:${message.port}`)
devServer.setAddress(`http://127.0.0.1:${message.port}`)
} else if (message.type === 'nuxt:internal:dev:loading') {
devServer.setAddress(undefined)
devServer.setLoadingMessage(message.message)
Expand Down

0 comments on commit 2cbe236

Please sign in to comment.