fix(blossom): CORS headers required by noStrudel

This commit is contained in:
Anthony Accioly
2024-10-31 05:06:58 +00:00
committed by fiatjaf_
parent b617fea679
commit 1c15db2ca1
2 changed files with 8 additions and 2 deletions

View File

@@ -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)

View File

@@ -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) {