api: use webui.ServeSPA in NotFound handler instead of buggy inline logic

This commit is contained in:
2026-07-07 15:58:18 -04:00
parent 68592bd119
commit 38a89328a9
+1 -11
View File
@@ -81,17 +81,7 @@ func NewServer(cfg *config.Config, db *sql.DB, engine *syncengine.Engine) *Serve
}))
r.NotFound(func(w http.ResponseWriter, r *http.Request) {
if _, ok := webui.DistFS.Open("dist" + r.URL.Path); ok == nil {
http.FileServer(http.FS(webui.DistFS)).ServeHTTP(w, r)
return
}
data, err := webui.DistFS.ReadFile("dist/index.html")
if err != nil {
http.Error(w, "not found", http.StatusNotFound)
return
}
w.Header().Set("Content-Type", "text/html")
w.Write(data)
webui.ServeSPA().ServeHTTP(w, r)
})
return s