fix(server): set no-cache headers on index.html to prevent stale SPA bundles

This commit is contained in:
2026-07-27 09:16:18 -04:00
parent beb04196ca
commit e927dd2cb0
+4
View File
@@ -446,9 +446,13 @@ func main() {
// If the file exists, serve it; otherwise serve index.html (SPA fallback) // If the file exists, serve it; otherwise serve index.html (SPA fallback)
path := staticDir + r.URL.Path path := staticDir + r.URL.Path
if _, err := os.Stat(path); os.IsNotExist(err) { if _, err := os.Stat(path); os.IsNotExist(err) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
http.ServeFile(w, r, staticDir+"/index.html") http.ServeFile(w, r, staticDir+"/index.html")
return return
} }
if r.URL.Path == "/" || r.URL.Path == "/index.html" {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
}
fileServer.ServeHTTP(w, r) fileServer.ServeHTTP(w, r)
}) })
} }