From e4364b0c2f72cc899103424acb37bf0ea535140b Mon Sep 17 00:00:00 2001 From: erangel1 Date: Thu, 7 May 2026 23:33:24 +0200 Subject: [PATCH] fixed problem with '/' causing loading issues with application --- internal/api/router.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/api/router.go b/internal/api/router.go index f1f35af..dcbcb26 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -6,6 +6,7 @@ import ( "net/http" "net/http/httputil" "net/url" + "strings" "github.com/go-chi/chi/v5" chimiddleware "github.com/go-chi/chi/v5/middleware" @@ -232,7 +233,12 @@ func mustParseURL(raw string) *url.URL { func spaHandler(staticFiles fs.FS) http.Handler { fileServer := http.FileServer(http.FS(staticFiles)) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, err := staticFiles.Open(r.URL.Path) + // fs.FS paths must not have a leading slash. + path := strings.TrimPrefix(r.URL.Path, "/") + if path == "" { + path = "." + } + _, err := staticFiles.Open(path) if err != nil { r.URL.Path = "/" }