fix(gateway): preserve unbracketed IPv6 host headers

This commit is contained in:
Rain
2026-02-16 20:54:31 +08:00
committed by Peter Steinberger
parent 8e55503d77
commit 4e5a9d83b7
2 changed files with 17 additions and 0 deletions

View File

@@ -40,6 +40,10 @@ export function resolveHostName(hostHeader?: string): string {
return host.slice(1, end);
}
}
// Unbracketed IPv6 host (e.g. "::1") has no port and should be returned as-is.
if (net.isIP(host) === 6) {
return host;
}
const [name] = host.split(":");
return name ?? "";
}