You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the Fetch standard, neither request is a preflight request, because
the first one lacks both an Origin header and an Access-Control-Request-Method header, and
the second one lacks an Access-Control-Request-Method header.
However, those requests get interpreted as preflight requests and handled by the CORS middleware rather than by the handler registered on OPTIONS /hello:
HTTP/1.1 204 No ContentDate: [REDACTED]Vary: Origin, Access-Control-Request-Method, Access-Control-Request-HeadersAccess-Control-Allow-Origin: *Access-Control-Allow-Methods: PUT
Expected Behavior
The first two aforementioned OPTIONS requests should get through the CORS middleware, exercise the handler registered on /hello, and get a response of this kind:
HTTP/1.1 204 No ContentAllow: GET, OPTIONSDate: [REDACTED]
gaby
changed the title
🐛 [Bug]: the CORS middleware misclassifies all OPTIONS requests as preflight requests
🐛 [Bug]: CORS middleware misclassifies all OPTIONS requests as preflight requests
Mar 17, 2024
Bug Description
Fiber's CORS middleware misclassifies all
OPTIONS
requests as preflight requests, thereby unduly preventing requests from hitting user-registeredOPTIONS
endpoints. I've discussed the general problem on my personal blog.How to Reproduce
Start the server, then exercise it by sending the
OPTIONS
requests resulting from the following twocurl
commands:curl -v -XOPTIONS \ -H "Origin: https://example.com" \ localhost:8080/hello
According to the Fetch standard, neither request is a preflight request, because
Origin
header and anAccess-Control-Request-Method
header, andAccess-Control-Request-Method
header.However, those requests get interpreted as preflight requests and handled by the CORS middleware rather than by the handler registered on
OPTIONS /hello
:Expected Behavior
The first two aforementioned
OPTIONS
requests should get through the CORS middleware, exercise the handler registered on/hello
, and get a response of this kind:Fiber Version
v2.52.2
Code Snippet
Checklist:
The text was updated successfully, but these errors were encountered: