Merge pull request 'Fix scheme determination behind reverse proxies' (#23) from fix/mixed into dev
build / Go-Build (push) Successful in 1m27s
build / Go-Build (push) Successful in 1m27s
Reviewed-on: #23
This commit was merged in pull request #23.
This commit is contained in:
@@ -104,9 +104,18 @@ func getPublicUrl(r *http.Request, subpath string) string {
|
||||
Host: r.Host,
|
||||
Path: path.Join("public", subpath),
|
||||
}
|
||||
newURL.Scheme = "http"
|
||||
if r.TLS != nil {
|
||||
newURL.Scheme = "https"
|
||||
}
|
||||
newURL.Scheme = determineScheme(r)
|
||||
return newURL.String()
|
||||
}
|
||||
|
||||
func determineScheme(r *http.Request) string {
|
||||
if proto := r.Header.Get("X-Forwarded-Proto"); proto != "" {
|
||||
return proto
|
||||
}
|
||||
|
||||
if r.TLS != nil {
|
||||
return "https"
|
||||
}
|
||||
|
||||
return "http"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user