From fc80f4f44c856ddc19df3024c245990fffd55630 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 14 Mar 2026 09:30:35 +0100 Subject: [PATCH] fix: base url/reverse proxy redirect --- http/utils.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/http/utils.go b/http/utils.go index c76cecf4..dc51ccb6 100644 --- a/http/utils.go +++ b/http/utils.go @@ -60,6 +60,15 @@ func stripPrefix(prefix string, h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { p := strings.TrimPrefix(r.URL.Path, prefix) rp := strings.TrimPrefix(r.URL.RawPath, prefix) + + // If the path is exactly the prefix (no trailing slash), redirect to + // the prefix with a trailing slash so the router receives "/" instead + // of "", which would otherwise cause a redirect to the site root. + if p == "" { + http.Redirect(w, r, prefix+"/", http.StatusMovedPermanently) + return + } + r2 := new(http.Request) *r2 = *r r2.URL = new(url.URL)