echo icon indicating copy to clipboard operation
echo copied to clipboard

Add configurable preflight status code for CORS middleware

Open dneto opened this issue 9 months ago • 0 comments

Hello! I'm adding support to configurable status code for CORS preflight response.

Changes:

  • middleware/cors.go:
    • Adds the field PreflightStatusCode to CORSConfig struct
    • Sets http.NoContent as default value for PreflightStatusCode field, keeping the original behavior
  • middleware/cors_test.go
    • Add TestCORSWithConfig_PreflightStatusCode with both default and custom status code scenarios

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.

dneto avatar Apr 11 '25 00:04 dneto