1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-18 16:35:19 +00:00

Fix x-api-host when setting ports

This commit is contained in:
Darren Shepherd
2020-02-21 13:17:12 -07:00
parent bf773d0210
commit b16f3160d5

View File

@@ -46,9 +46,11 @@ func ParseRequestURL(r *http.Request) string {
func GetHost(r *http.Request, scheme string) string {
host := r.Header.Get(ForwardedAPIHostHeader)
if host == "" {
host = strings.Split(r.Header.Get(ForwardedHostHeader), ",")[0]
if host != "" {
return host
}
host = strings.Split(r.Header.Get(ForwardedHostHeader), ",")[0]
if host == "" {
host = r.Host
}
@@ -68,7 +70,7 @@ func GetHost(r *http.Request, scheme string) string {
hostname, _, err := net.SplitHostPort(host)
if err != nil {
return host
hostname = host
}
return strings.Join([]string{hostname, port}, ":")