Files
svg-templater/internal/server/corsmiddleware.go
T
tueem 7347565cda
build / Go-Build (push) Failing after 14m14s
fix(cors): add PATCH to allowed CORS methods
2026-05-27 23:59:18 +02:00

17 lines
489 B
Go

package server
import "net/http"
func corsMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
if r.Method == "OPTIONS" {
w.WriteHeader(http.StatusOK)
return
}
next.ServeHTTP(w, r)
})
}