diff --git a/internal/api/http/header.go b/internal/api/http/header.go index 858312789a..beb3b53a57 100644 --- a/internal/api/http/header.go +++ b/internal/api/http/header.go @@ -77,7 +77,8 @@ func RemoteIPStringFromRequest(r *http.Request) string { if ok { return ip } - return r.RemoteAddr + host, _, _ := net.SplitHostPort(r.RemoteAddr) + return host } func GetAuthorization(r *http.Request) string { @@ -91,7 +92,7 @@ func GetOrgID(r *http.Request) string { func GetForwardedFor(headers http.Header) (string, bool) { forwarded, ok := headers[ForwardedFor] if ok { - ip := strings.Split(forwarded[0], ", ")[0] + ip := strings.TrimSpace(strings.Split(forwarded[0], ",")[0]) if ip != "" { return ip, true }