From 4a850ff8a059d98d8b41716c4aabf44d53af1b73 Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Fri, 3 Apr 2020 14:40:24 +0100 Subject: [PATCH] Auth host fix --- api/server/auth/auth.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/api/server/auth/auth.go b/api/server/auth/auth.go index 186e71c7..ad75a93d 100644 --- a/api/server/auth/auth.go +++ b/api/server/auth/auth.go @@ -102,9 +102,10 @@ func (h authHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { func namespaceFromRequest(req *http.Request) (string, error) { // determine the host, e.g. dev.micro.mu:8080 - host := req.URL.Host + host := req.URL.Hostname() if len(host) == 0 { - host = req.Host + // fallback to req.Host + host, _, _ = net.SplitHostPort(req.Host) } // check for an ip address @@ -112,12 +113,6 @@ func namespaceFromRequest(req *http.Request) (string, error) { return auth.DefaultNamespace, nil } - // split the host to remove the port - host, _, err := net.SplitHostPort(req.Host) - if err != nil { - return "", err - } - // check for dev enviroment if host == "localhost" || host == "127.0.0.1" { return auth.DefaultNamespace, nil