Skip to content

Commit 5db0ce4

Browse files
ilopezlunaCopilot
andauthored
Update pkg/middleware/cors.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b9d8376 commit 5db0ce4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/middleware/cors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88

99
// CorsMiddleware handles CORS and OPTIONS preflight requests with optional allowedOrigins.
1010
// If allowedOrigins is nil or empty, it falls back to getAllowedOrigins().
11-
// This middleware intercepts ALL OPTIONS requests globally, preventing them from reaching
12-
// the router and avoiding 405 Method Not Allowed errors.
11+
// This middleware intercepts OPTIONS requests only if the Origin header is present and valid,
12+
// otherwise passing the request to the router (allowing 405/404 responses as appropriate).
1313
func CorsMiddleware(allowedOrigins []string, next http.Handler) http.Handler {
1414
if len(allowedOrigins) == 0 {
1515
allowedOrigins = getAllowedOrigins()

0 commit comments

Comments
 (0)