mirror of
https://github.com/filebrowser/filebrowser.git
synced 2026-07-18 08:55:24 +00:00
fix: base url/reverse proxy redirect
This commit is contained in:
parent
6aea227617
commit
fc80f4f44c
1 changed files with 9 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue