Reduce number of preflight check to save network brandwidth

This commit is contained in:
Pascal Noisette 2022-05-07 12:01:59 +02:00 committed by Frédéric Guillot
parent a6e9f88e7a
commit cdeb2a8fc0
1 changed files with 1 additions and 0 deletions

View File

@ -27,6 +27,7 @@ func (m *middleware) handleCORS(next http.Handler) http.Handler {
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "X-Auth-Token")
if r.Method == http.MethodOptions {
w.Header().Set("Access-Control-Max-Age", "3600")
w.WriteHeader(http.StatusOK)
return
}