fix(server): set no-cache headers on index.html to prevent stale SPA bundles
This commit is contained in:
@@ -446,9 +446,13 @@ func main() {
|
||||
// If the file exists, serve it; otherwise serve index.html (SPA fallback)
|
||||
path := staticDir + r.URL.Path
|
||||
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")
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user