Skip to content

Conversation

jurakin
Copy link

@jurakin jurakin commented Jun 1, 2024

Description

This pull request adds support for handling CORS preflight requests in the routing system. The router will respond to OPTIONS requests only when the route actually exists and a preflight setting is enabled. The setting is disabled by default.

Changes

  • Added a preflight setting to enable handling of preflight requests.
  • When the setting is enabled, the router responds to OPTIONS requests with status 200 OK and no content, following the MDN documentation.
  • Added unit tests and README documentation.

Usage

// single route
SimpleRouter::form('foo', function () {
    // ...
})->setSettings(['preflight' => true]);

// group routes
SimpleRouter::group(['preflight' => true], function () {
    SimpleRouter::form('foo', function() {
        // ...
    });
});
  • Requesting OPTIONS /foo will return HTTP/1.1 200 OK.
  • Requesting POST /foo will proceed normally.

skipperbent and others added 18 commits November 21, 2023 16:15
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.

2 participants