fix: resolve forcetypeassert lint issues

This commit is contained in:
user
2026-02-20 03:21:14 -08:00
parent 0be5e80b85
commit 2c89b23bea

View File

@@ -73,10 +73,17 @@ func (s *Server) SetupRoutes() {
fileServer := http.FileServer(http.FS(distFS))
s.router.Get("/*", func(w http.ResponseWriter, r *http.Request) {
readFS, ok := distFS.(fs.ReadFileFS)
if !ok {
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
// Try to serve the file; if not found, serve index.html for SPA routing
f, err := distFS.(fs.ReadFileFS).ReadFile(r.URL.Path[1:])
f, err := readFS.ReadFile(r.URL.Path[1:])
if err != nil || len(f) == 0 {
indexHTML, _ := distFS.(fs.ReadFileFS).ReadFile("index.html")
indexHTML, _ := readFS.ReadFile("index.html")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)