summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-30 09:31:49 +0300
committerPaul Buetow <paul@buetow.org>2026-04-30 09:31:49 +0300
commite971128cdc64aa81bba134faa65dc53bc2680d60 (patch)
tree79d9ca14ba3d18819bba58bf5d33633c6a88b5dd /internal/api
parentc981bc27472c581cd19e438f876edc0ba92627b8 (diff)
fix: allow static assets during bootstrap when no users exist
The BootstrapRedirect middleware was blocking /css/ and /js/ requests when no users existed, which prevented the bootstrap.html page from loading its stylesheets and scripts. This caused the form to submit as raw form data (rather than JSON via the JS API) and silently fail. - Added /css/* and /js/* to isBootstrapPublic() so static assets are served without redirect when no users exist. - Also added /images/, /favicon.svg, /manifest.json, and /sw.js for completeness.
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/middleware.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/api/middleware.go b/internal/api/middleware.go
index 70da80b..5b99cc7 100644
--- a/internal/api/middleware.go
+++ b/internal/api/middleware.go
@@ -3,6 +3,7 @@ package api
import (
"context"
"net/http"
+ "strings"
"github.com/paul/kiss-media-player/internal/auth"
"github.com/paul/kiss-media-player/internal/model"
@@ -85,7 +86,11 @@ func (mw *Middleware) BootstrapRedirect(next http.Handler) http.Handler {
func isBootstrapPublic(path string) bool {
switch path {
- case "/bootstrap.html", "/api/bootstrap", "/login.html", "/api/login", "/healthz", "/readyz":
+ case "/bootstrap.html", "/api/bootstrap", "/login.html", "/api/login", "/healthz", "/readyz",
+ "/favicon.svg", "/manifest.json", "/sw.js":
+ return true
+ }
+ if strings.HasPrefix(path, "/css/") || strings.HasPrefix(path, "/js/") || strings.HasPrefix(path, "/images/") {
return true
}
return false