Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/srv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down