Skip to content

Commit

Permalink
fix: server.host with ipv6 missed [] (fix vitejs#11466)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan committed Dec 28, 2022
1 parent 13ac37d commit a14e310
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/node/utils.ts
Expand Up @@ -886,7 +886,11 @@ export async function resolveServerUrls(
(typeof detail.family === 'number' && detail.family === 4)),
)
.forEach((detail) => {
const host = detail.address.replace('127.0.0.1', hostname.name)
let host = detail.address.replace('127.0.0.1', hostname.name)
// ipv6 host
if (host.indexOf(':') > -1) {
host = `[${host}]`
}
const url = `${protocol}://${host}:${port}${base}`
if (detail.address.includes('127.0.0.1')) {
local.push(url)
Expand Down

0 comments on commit a14e310

Please sign in to comment.