From 05ac3ff274c539e0ab918dc05df0604c322f0fec Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Tue, 7 Apr 2020 11:24:13 +0100 Subject: [PATCH] Tweak --- api/server/auth/auth.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/api/server/auth/auth.go b/api/server/auth/auth.go index 0faf1447..7ae99214 100644 --- a/api/server/auth/auth.go +++ b/api/server/auth/auth.go @@ -141,10 +141,12 @@ func (h authHandler) NamespaceFromRequest(req *http.Request) string { // determine the host, e.g. dev.micro.mu:8080 host := req.URL.Hostname() - if h, _, err := net.SplitHostPort(req.Host); err == nil { - host = h // host does contain a port - } else if strings.Contains(err.Error(), "missing port in address") { - host = req.Host // host does not contain a port + if len(host) == 0 { + if h, _, err := net.SplitHostPort(req.Host); err == nil { + host = h // host does contain a port + } else if strings.Contains(err.Error(), "missing port in address") { + host = req.Host // host does not contain a port + } } // check for an ip address