diff --git a/blossom/server.go b/blossom/server.go index 3b27962..653756f 100644 --- a/blossom/server.go +++ b/blossom/server.go @@ -33,6 +33,12 @@ func New(rl *khatru.Relay, serviceURL string) *BlossomServer { mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + if r.Method == "OPTIONS" { + setCors(w) + w.WriteHeader(http.StatusNoContent) + return + } + if r.URL.Path == "/upload" { if r.Method == "PUT" { setCors(w) diff --git a/blossom/utils.go b/blossom/utils.go index a9ec9cc..5af0d0d 100644 --- a/blossom/utils.go +++ b/blossom/utils.go @@ -7,8 +7,8 @@ import ( func setCors(w http.ResponseWriter) { w.Header().Set("Access-Control-Allow-Origin", "*") - w.Header().Set("Access-Control-Allow-Headers", "Authorization") - w.Header().Set("Access-Control-Allow-Methods", "GET PUT DELETE") + w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type") + w.Header().Set("Access-Control-Allow-Methods", "GET, PUT, DELETE, OPTIONS") } func blossomError(w http.ResponseWriter, msg string, code int) {