From 2cbe2362b82243431dea76b63d392608867c8542 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 30 Aug 2023 13:21:12 +0200 Subject: [PATCH] fix: prefer ipv4 stack for windows, wsl2 and internals --- package.json | 2 +- pnpm-lock.yaml | 12 ++++++------ src/commands/dev-internal.ts | 8 ++++---- src/commands/dev.ts | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index f02f2db7..8e2f0520 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02678d42..19ed5062 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,8 +98,8 @@ devDependencies: specifier: ^1.19.3 version: 1.19.3 listhen: - specifier: ^1.4.3 - version: 1.4.3 + specifier: ^1.4.4 + version: 1.4.4 magicast: specifier: ^0.2.10 version: 0.2.10 @@ -3871,8 +3871,8 @@ packages: engines: {node: '>=10'} dev: true - /listhen@1.4.3: - resolution: {integrity: sha512-qVWeM07q7q5R3jwB+Zm603khFQ3yq5OLmAwLIlE3Ftv1K9yfwx4R6/tbCkkr0/SrIyKnHK9xY1C6j03uGOSnIQ==} + /listhen@1.4.4: + resolution: {integrity: sha512-xoZWbfziou7xPWj9nlFXeroFTJZVIyJ6wKrLea2jxvWgMkcz/vLMoZACYHLRmcLGi5hZkcDF48tmkmv1Y6Y42Q==} hasBin: true dependencies: '@parcel/watcher': 2.3.0 @@ -4224,7 +4224,7 @@ packages: jiti: 1.19.3 klona: 2.0.6 knitwork: 1.0.0 - listhen: 1.4.3 + listhen: 1.4.4 magic-string: 0.30.3 mime: 3.0.0 mlly: 1.4.1 @@ -5805,7 +5805,7 @@ packages: destr: 2.0.1 h3: 1.8.1 ioredis: 5.3.2 - listhen: 1.4.3 + listhen: 1.4.4 lru-cache: 10.0.1 mri: 1.2.0 node-fetch-native: 1.4.0 diff --git a/src/commands/dev-internal.ts b/src/commands/dev-internal.ts index a51b893b..f9821b06 100644 --- a/src/commands/dev-internal.ts +++ b/src/commands/dev-internal.ts @@ -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}`) } @@ -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(), @@ -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 diff --git a/src/commands/dev.ts b/src/commands/dev.ts index ee1dd499..9f27fc04 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -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)