Visitar URL original
fix: only show the listened IP when host is specified (#13412) · vitejs/vite@20b0cae · GitHub
Skip to content

Commit 20b0cae

Browse files
authored
fix: only show the listened IP when host is specified (#13412)
1 parent bf0cd25 commit 20b0cae

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎packages/vite/src/node/utils.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,13 +881,18 @@ export async function resolveServerUrls(
881881
const base =
882882
config.rawBase === './' || config.rawBase === '' ? '/' : config.rawBase
883883

884-
if (hostname.host && loopbackHosts.has(hostname.host)) {
884+
if (hostname.host) {
885885
let hostnameName = hostname.name
886886
// ipv6 host
887887
if (hostnameName.includes(':')) {
888888
hostnameName = `[${hostnameName}]`
889889
}
890-
local.push(`${protocol}://${hostnameName}:${port}${base}`)
890+
const address = `${protocol}://${hostnameName}:${port}${base}`
891+
if (loopbackHosts.has(hostname.host)) {
892+
local.push(address)
893+
} else {
894+
network.push(address)
895+
}
891896
} else {
892897
Object.values(os.networkInterfaces())
893898
.flatMap((nInterface) => nInterface ?? [])

0 commit comments

Comments
 (0)