aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/httputil/httpapi.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/httputil/httpapi.go b/internal/httputil/httpapi.go
index 0559fbb7..034f19f1 100644
--- a/internal/httputil/httpapi.go
+++ b/internal/httputil/httpapi.go
@@ -210,6 +210,12 @@ func MakeExternalAPI(metricsName string, f func(*http.Request) util.JSONResponse
// This is used to serve HTML alongside JSON error messages
func MakeHTTPAPI(metricsName string, userAPI userapi.QueryAcccessTokenAPI, enableMetrics bool, f func(http.ResponseWriter, *http.Request), checks ...AuthAPIOption) http.Handler {
withSpan := func(w http.ResponseWriter, req *http.Request) {
+ if req.Method == http.MethodOptions {
+ util.SetCORSHeaders(w)
+ w.WriteHeader(http.StatusOK) // Maybe http.StatusNoContent?
+ return
+ }
+
trace, ctx := internal.StartTask(req.Context(), metricsName)
defer trace.EndTask()
req = req.WithContext(ctx)