Detect scheme correct when behind a reverse proxy

This commit is contained in:
Vikas
2024-06-03 00:39:49 +05:30
parent 87aebd120e
commit 9767b4b25d

View File

@@ -47,11 +47,12 @@ func (h *Handler) Paste(w http.ResponseWriter, r *http.Request) {
}
var scheme string
if r.TLS == nil {
scheme = "http"
if r.Header.Get("X-Forwarded-Proto") != "" {
scheme = r.Header.Get("X-Forwarded-Proto")
} else {
scheme = "https"
scheme = "http"
}
url := fmt.Sprintf("%s://%s/p/%s/%s", scheme, r.Host, paste.ID, paste.Key)
component := views.PasteSuccess(url)