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
A single file solution with CorsMiddleware.php worked like a charm with Lumen 8.x. The only issue I had that my .htaccess file was not default and was adjusted with the following command:
In my case I had to remove these lines to make things work.