Browse Source

Remove a double slash in the HTTPS redirection when Let's Encrypt is enabled (#5537)

Before:

$ curl 0.0.0.0:3001
<a href="https://gitea.example.com:3000//">Found</a>.

After:

$ curl 0.0.0.0:3001
<a href="https://gitea.example.com:3000/">Found</a>.

Fixes #5536
for-closed-social
Greg Karékinian 5 years ago
committed by Lauris BH
parent
commit
ebef3eff23
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      cmd/web.go

+ 4
- 1
cmd/web.go View File

@ -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)
}

Loading…
Cancel
Save