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
Hello everyone again. I solved my error related to this issue. I share my answer with you below.
Due to the middleware structure, it returns and switches to the next request after processing. If an error is encountered after the request middleware has passed and did not return, the return value will be null.
For example, after I pass the request from the cors middleware, I am sending a mail via a event as a result of a series of operations. However, even though I changed the mail blade I sent, the cors middleware response value returns null because the php document created in ~/storage/framework/views does not update, and an error occurs.
https://stackoverflow.com/questions/68739232/call-to-a-member-function-header-on-null-in-cors-middleware-in-lumen/68760328#68760328