This commit is contained in:
Erik Johnston 2017-12-05 18:06:12 +00:00
parent 7d67791d17
commit 41e17b6322

View file

@ -102,6 +102,10 @@ func WrapHandlerInCORS(h http.Handler) http.HandlerFunc {
w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization") w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization")
if r.Method == "OPTIONS" && r.Header.Get("Access-Control-Request-Method") != "" { if r.Method == "OPTIONS" && r.Header.Get("Access-Control-Request-Method") != "" {
// Its easiest just to always return a 200 OK for everything. Whether
// this is technically correct or not is a question, but in the end this
// is what a lot of other people do (including synapse) and the clients
// are perfectly happy with it.
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
} else { } else {
h.ServeHTTP(w, r) h.ServeHTTP(w, r)