mirror of
https://github.com/niusmallnan/steve.git
synced 2025-06-24 05:37:05 +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 {
|
||||
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
|
||||
}
|
||||
@ -39,7 +41,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}, ":")
|
||||
|
Loading…
Reference in New Issue
Block a user