fix(cookie): net/http: invalid Cookie.Domain .0.0.1:3000

This commit is contained in:
yusing
2025-10-13 07:09:17 +08:00
parent dcc5ab8952
commit d41c6f8d77

View File

@@ -59,6 +59,17 @@ func cookieDomain(r *http.Request) string {
return ".local"
}
// if the host is an IP address, return an empty string
{
host, _, err := net.SplitHostPort(reqHost)
if err != nil {
host = reqHost
}
if net.ParseIP(host) != nil {
return ""
}
}
parts := strutils.SplitRune(reqHost, '.')
if len(parts) < 2 {
return ""