fix: no-cache headers to prevent stale JS, correct go2rtc stream.html URL
This commit is contained in:
parent
03448361da
commit
741983ae82
1 changed files with 5 additions and 1 deletions
|
|
@ -75,12 +75,16 @@ func (s *Server) registerRoutes() {
|
||||||
s.mux.Handle("/", http.FileServer(http.FS(publicFS)))
|
s.mux.Handle("/", http.FileServer(http.FS(publicFS)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// middleware wraps handlers with CORS and logging.
|
// middleware wraps handlers with CORS, no-cache, and logging.
|
||||||
func (s *Server) middleware(next http.Handler) http.Handler {
|
func (s *Server) middleware(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
|
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
|
||||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||||
|
// Prevent caching of static files during development.
|
||||||
|
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
|
w.Header().Set("Pragma", "no-cache")
|
||||||
|
w.Header().Set("Expires", "0")
|
||||||
|
|
||||||
if r.Method == "OPTIONS" {
|
if r.Method == "OPTIONS" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue