mirror of
https://github.com/niusmallnan/steve.git
synced 2025-06-25 06:01:35 +00:00
Fix x-api-host when port is set
This commit is contained in:
parent
5b94b82bc6
commit
c069f32bbe
@ -17,9 +17,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
|
||||||
}
|
}
|
||||||
@ -39,7 +41,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}, ":")
|
||||||
|
Loading…
Reference in New Issue
Block a user