diff options
| -rw-r--r-- | backend/router.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/backend/router.go b/backend/router.go index 4c3b2f8..f5d0cc6 100644 --- a/backend/router.go +++ b/backend/router.go @@ -61,9 +61,13 @@ func HandleStaticFiles(r *chi.Mux, path string, root fs.FS) { } path += "*" - r.Get(path, func(w http.ResponseWriter, r *http.Request) { - ctx := chi.RouteContext(r.Context()) + r.Get(path, func(w http.ResponseWriter, req *http.Request) { + ctx := chi.RouteContext(req.Context()) pathPrefix := strings.TrimSuffix(ctx.RoutePattern(), "/*") - http.StripPrefix(pathPrefix, http.FileServerFS(root)).ServeHTTP(w, r) + if pathPrefix+"/" == req.URL.Path { + r.NotFoundHandler().ServeHTTP(w, req) + return + } + http.StripPrefix(pathPrefix, http.FileServerFS(root)).ServeHTTP(w, req) }) } |
