We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b9d8376 commit 5db0ce4Copy full SHA for 5db0ce4
pkg/middleware/cors.go
@@ -8,8 +8,8 @@ import (
8
9
// CorsMiddleware handles CORS and OPTIONS preflight requests with optional allowedOrigins.
10
// 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.
+// This middleware intercepts OPTIONS requests only if the Origin header is present and valid,
+// otherwise passing the request to the router (allowing 405/404 responses as appropriate).
13
func CorsMiddleware(allowedOrigins []string, next http.Handler) http.Handler {
14
if len(allowedOrigins) == 0 {
15
allowedOrigins = getAllowedOrigins()
0 commit comments