Fix all lint/build issues on main branch (closes #13) #15

Closed
clawbot wants to merge 22 commits from fix/main-lint-issues into main
Showing only changes of commit 2c89b23bea - Show all commits

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)