React UI: Fix "<path-prefix>/new" -> "<path-prefix>/new/" redirect (#6319)
Fixes https://github.com/prometheus/prometheus/issues/6163 Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
be2bcc50a2
commit
8ee3b8c848
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in New Issue