Unverified Commit 8ee3b8c8 authored by Julius Volz's avatar Julius Volz Committed by GitHub
Browse files

React UI: Fix "<path-prefix>/new" -> "<path-prefix>/new/" redirect (#6319)

Fixes https://github.com/prometheus/prometheus/issues/6163

Signed-off-by: default avatarJulius Volz <julius.volz@gmail.com>
parent be2bcc50
......@@ -347,6 +347,15 @@ func New(logger log.Logger, o *Options) *Handler {
fs.ServeHTTP(w, r)
})
// Make sure that "<path-prefix>/new" is redirected to "<path-prefix>/new/" and
// not just the naked "/new/", which would be the default behavior of the router
// with the "RedirectTrailingSlash" option (https://godoc.org/github.com/julienschmidt/httprouter#Router.RedirectTrailingSlash),
// and which breaks users with a --web.route-prefix that deviates from the path derived
// from the external URL.
router.Get("/new", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, path.Join(o.ExternalURL.Path, "new")+"/", http.StatusFound)
})
router.Get("/new/*filepath", func(w http.ResponseWriter, r *http.Request) {
p := route.Param(r.Context(), "filepath")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment