Skip to content

Commit 260f120

Browse files
notjulianjcsoft-dev
authored andcommitted
Update api.go
1 parent cc7216b commit 260f120

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

internal/api/api.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ func middlewareCORS(next http.Handler) http.Handler {
215215
w.Header().Set("Access-Control-Allow-Origin", "*")
216216
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
217217
w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type")
218+
219+
// Handle preflight OPTIONS request
220+
if r.Method == http.MethodOptions {
221+
w.WriteHeader(http.StatusNoContent) // 204
222+
return
223+
}
224+
218225
next.ServeHTTP(w, r)
219226
})
220227
}

0 commit comments

Comments
 (0)