echo
echo copied to clipboard
Add configurable preflight status code for CORS middleware
Hello! I'm adding support to configurable status code for CORS preflight response.
Changes:
-
middleware/cors.go:- Adds the field
PreflightStatusCodetoCORSConfigstruct - Sets
http.NoContentas default value forPreflightStatusCodefield, keeping the original behavior
- Adds the field
-
middleware/cors_test.go- Add
TestCORSWithConfig_PreflightStatusCodewith both default and custom status code scenarios
- Add
According do MDN Reference both 200 and 204 are allowed, but checking this spec it says any 2XX is an ok status which made me create PreflightStatusCode as an int rather than a bool ReturnStatusOkInPreflight or something like that.