remove redundant fallback host

This commit is contained in:
sentriz
2023-11-26 15:31:06 +00:00
parent d989fd02ae
commit 707ebe1a49

View File

@@ -69,21 +69,20 @@ func Message(message string) http.Handler {
}
func BaseURL(r *http.Request) string {
fallbackProtocoll := "http"
var fallbackScheme = "http"
if r.TLS != nil {
fallbackProtocoll = "https"
fallbackScheme = "https"
}
fallbackHost := "localhost:4747"
scheme := first(
r.Header.Get("X-Forwarded-Proto"),
r.Header.Get("X-Forwarded-Scheme"),
r.URL.Scheme,
fallbackProtocoll,
fallbackScheme,
)
host := first(
r.Header.Get("X-Forwarded-Host"),
r.URL.Host,
r.Host,
fallbackHost,
)
return fmt.Sprintf("%s://%s", scheme, host)
}