Browse Source

Add DELETE method to CORS header

Frédéric Guillot 5 years ago
parent
commit
ec18abc97f
1 changed files with 2 additions and 2 deletions
  1. 2 2
      api/middleware.go

+ 2 - 2
api/middleware.go

@@ -24,9 +24,9 @@ func newMiddleware(s *storage.Storage) *middleware {
 func (m *middleware) handleCORS(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, OPTIONS")
+		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 == "OPTIONS" {
+		if r.Method == http.MethodOptions {
 			w.WriteHeader(http.StatusOK)
 			return
 		}