From d41c6f8d778bb5fe34cadd3b46c38dab4da4113b Mon Sep 17 00:00:00 2001 From: yusing Date: Mon, 13 Oct 2025 07:09:17 +0800 Subject: [PATCH] fix(cookie): net/http: invalid Cookie.Domain .0.0.1:3000 --- internal/auth/utils.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/auth/utils.go b/internal/auth/utils.go index d7d2bd53..f674b286 100644 --- a/internal/auth/utils.go +++ b/internal/auth/utils.go @@ -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 ""