Conversation

dneto

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.

@dnetodneto force-pushed the preflight_status_code branch from 7e4f71a to 2fabaf9 Compare April 11, 2025 00:33
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

@dneto