Skip to content

Commit

Permalink
Merge pull request #348 from ibuildthecloud/clientconfig
Browse files Browse the repository at this point in the history
Fix x-api-host when setting ports
  • Loading branch information
ibuildthecloud authored Feb 21, 2020
2 parents bf773d0 + b16f316 commit 9bd5ca9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions urlbuilder/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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}, ":")
Expand Down

0 comments on commit 9bd5ca9

Please sign in to comment.