fix(download): fix scheme determination behind reverse proxies
This commit is contained in:
@@ -104,9 +104,18 @@ func getPublicUrl(r *http.Request, subpath string) string {
|
|||||||
Host: r.Host,
|
Host: r.Host,
|
||||||
Path: path.Join("public", subpath),
|
Path: path.Join("public", subpath),
|
||||||
}
|
}
|
||||||
newURL.Scheme = "http"
|
newURL.Scheme = determineScheme(r)
|
||||||
if r.TLS != nil {
|
|
||||||
newURL.Scheme = "https"
|
|
||||||
}
|
|
||||||
return newURL.String()
|
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