mirror of
https://github.com/rancher/norman.git
synced 2025-09-19 18:16:15 +00:00
Fix x-api-host when setting ports
This commit is contained in:
@@ -46,9 +46,11 @@ func ParseRequestURL(r *http.Request) string {
|
|||||||
|
|
||||||
func GetHost(r *http.Request, scheme string) string {
|
func GetHost(r *http.Request, scheme string) string {
|
||||||
host := r.Header.Get(ForwardedAPIHostHeader)
|
host := r.Header.Get(ForwardedAPIHostHeader)
|
||||||
if host == "" {
|
if host != "" {
|
||||||
host = strings.Split(r.Header.Get(ForwardedHostHeader), ",")[0]
|
return host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
host = strings.Split(r.Header.Get(ForwardedHostHeader), ",")[0]
|
||||||
if host == "" {
|
if host == "" {
|
||||||
host = r.Host
|
host = r.Host
|
||||||
}
|
}
|
||||||
@@ -68,7 +70,7 @@ func GetHost(r *http.Request, scheme string) string {
|
|||||||
|
|
||||||
hostname, _, err := net.SplitHostPort(host)
|
hostname, _, err := net.SplitHostPort(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return host
|
hostname = host
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join([]string{hostname, port}, ":")
|
return strings.Join([]string{hostname, port}, ":")
|
||||||
|
Reference in New Issue
Block a user