From 200b974e198f5a18bf8b6638e1f8f21de17602fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Thu, 13 Dec 2018 16:42:38 +0100 Subject: [PATCH] Backport #5537 Remove a double slash in the HTTPS redirect with Let's Encrypt (#5539) Before: $ curl 0.0.0.0:3001 Found. After: $ curl 0.0.0.0:3001 Found. Fixes #5536 --- cmd/web.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/web.go b/cmd/web.go index b6c014a2e..8fed559ff 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -102,7 +102,10 @@ func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, "Use HTTPS", http.StatusBadRequest) return } - target := setting.AppURL + r.URL.RequestURI() + // Remove the trailing slash at the end of setting.AppURL, the request + // URI always contains a leading slash, which would result in a double + // slash + target := strings.TrimRight(setting.AppURL, "/") + r.URL.RequestURI() http.Redirect(w, r, target, http.StatusFound) }