Register the CatchAllOptionsRequestsProvider
service provider in bootstrap/app.php
which will check the incoming request and response successfully if it is an OPTIONS
request.
Add the CorsMiddleware
to the $app->middleware([
array in bootstrap/app.php
which will attach the following CORS headers to all responses:
- allow all headers
- allow requests from all origins
- allow all the headers which were provided in the request
Thank you so much this really helped me out!
Don't know if anyone had to do the same thing, but I had to do
$app->options('/card', ['middleware' => 'cors', '']);
$app->post('/card', ['middleware' => 'cors', 'uses' => 'CardController@createCard']);
to make it work maybe I missing a step.