From b484a56f7c78f96389109bacdf06eafdf4875893 Mon Sep 17 00:00:00 2001 From: Lee <7932644+strahe@users.noreply.github.com> Date: Fri, 12 Sep 2025 17:34:30 +0800 Subject: [PATCH] Add OPTIONS route handler for CORS preflight requests --- web/srv.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/srv.go b/web/srv.go index 92d99ae48..624952d14 100644 --- a/web/srv.go +++ b/web/srv.go @@ -42,6 +42,11 @@ var webDev = os.Getenv("CURIO_WEB_DEV") == "1" func GetSrv(ctx context.Context, deps *deps.Deps, devMode bool) (*http.Server, error) { mx := mux.NewRouter() mx.Use(corsMiddleware) + mx.Methods(http.MethodOptions).PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Register OPTIONS routes for CORS preflight requests. + // Actual handling is done by corsMiddleware which intercepts + // all OPTIONS requests before they reach this handler. + }) if !devMode { api.Routes(mx.PathPrefix("/api").Subrouter(), deps, webDev)