FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add configurable preflight status code for CORS middleware by dneto · Pull Request #2765 · labstack/echo · GitHub

/ echo Public

Add configurable preflight status code for CORS middleware - #2765

Open
dneto wants to merge 2 commits into
labstack:masterfrom
dneto:preflight_status_code
Open

Add configurable preflight status code for CORS middleware#2765
dneto wants to merge 2 commits into
labstack:masterfrom
dneto:preflight_status_code

Conversation

dneto commented Apr 11, 2025
edited
Loading

Copy link
Copy Markdown

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 force-pushed the preflight_status_code branch from 7e4f71a to 2fabaf9 Compare April 11, 2025 00:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL