From 0ff648adb6fabe9afcbc924ad3b0ee91e89c2c37 Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Thu, 31 May 2018 12:52:43 -0700 Subject: [PATCH] UI: Trim trailing slashes to avoid redirects (#4668) --- http/handler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/http/handler.go b/http/handler.go index accb78dea0..f7d6437bb2 100644 --- a/http/handler.go +++ b/http/handler.go @@ -273,6 +273,11 @@ func handleUIHeaders(core *vault.Core, h http.Handler) http.Handler { func handleUI(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + + // The fileserver handler strips trailing slashes and does a redirect. + // We don't want the redirect to happen so we preemptively trim the slash + // here. + req.URL.Path = strings.TrimSuffix(req.URL.Path, "/") h.ServeHTTP(w, req) return })