Move OPTIONS response higher up
All checks were successful
the build was successful

This commit is contained in:
Peter Stuifzand 2018-08-26 18:54:45 +02:00
parent a4416164cd
commit 4693b95f77
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -45,6 +45,13 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log.Println(r.URL.Query())
log.Println(r.PostForm)
if r.Method == http.MethodOptions {
w.Header().Add("Access-Control-Allow-Origin", "*")
w.Header().Add("Access-Control-Allow-Methods", "GET, POST")
w.Header().Add("Access-Control-Allow-Headers", "Authorization")
return
}
if auth {
authorization := r.Header.Get("Authorization")
@ -63,13 +70,6 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
if r.Method == http.MethodOptions {
w.Header().Add("Access-Control-Allow-Origin", "*")
w.Header().Add("Access-Control-Allow-Methods", "GET, POST")
w.Header().Add("Access-Control-Allow-Headers", "Authorization")
return
}
if r.Method == http.MethodGet {
values := r.URL.Query()
action := values.Get("action")