From 505f0b9eefaf37172ed4bacef6d56c634e988ca1 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Sat, 3 Jun 2023 17:13:31 +0900 Subject: [PATCH] fix: only show the listened IP when host is specified --- packages/vite/src/node/utils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 990cc6aad92cb3..026c5abc370f43 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -881,13 +881,18 @@ export async function resolveServerUrls( const base = config.rawBase === './' || config.rawBase === '' ? '/' : config.rawBase - if (hostname.host && loopbackHosts.has(hostname.host)) { + if (hostname.host) { let hostnameName = hostname.name // ipv6 host if (hostnameName.includes(':')) { hostnameName = `[${hostnameName}]` } - local.push(`${protocol}://${hostnameName}:${port}${base}`) + const address = `${protocol}://${hostnameName}:${port}${base}` + if (loopbackHosts.has(hostname.host)) { + local.push(address) + } else { + network.push(address) + } } else { Object.values(os.networkInterfaces()) .flatMap((nInterface) => nInterface ?? [])