Simple, fast and yet powerful PHP router that is easy to get integrated and in any project. Heavily inspired by the way Laravel handles routing, with both simplicity and expand-ability in mind.
631
stars
116
forks
source link
Add support for handling CORS preflight requests #714
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.
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
preflight
setting to enable handling of preflight requests.OPTIONS
requests with status200 OK
and no content, following the MDN documentation.Usage
OPTIONS /foo
will returnHTTP/1.1 200 OK
.POST /foo
will proceed normally.