Answer the question
In order to leave comments, you need to log in
Lumen6 Cors error?
Good afternoon,
Lumen6 is on the back. I
configured Cors like this
https://www.codementor.io/@chiemelachinedum/steps-...
In dev everything works without problems, when I transferred it to production,
'Access-Control-Allow- Origin' => '*', //changed to front address here
But the request gives an error
Access to XMLHttpRequest at ' backsite.kz/login ' from origin ' frontsite.kz ' has been blocked by CORS policy: No 'Access-Control- Allow-Origin' header is present on the requested resource.
I configured axios.defaults.withCredentials = true in the front. I don’t
know how to solve it, I tried to add add header in nginx, but it’s also an error.
Answer the question
In order to leave comments, you need to log in
In general, I decided this way
1) Removed middleware Cors in Lumen in /bootstrap/app.php,
2) added
add_header 'Access-Control-Max-Age' 86400 to nginx in site.conf;
add_header 'Access-Control-Allow-Origin' " new.site.kz " always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept, Authorization, Cache-Control, Content-Type, Keep-Alive, Origin, User-Agent, X-Requested-With' always;
add_header 'Access-Control-Expose-Headers' 'Authorization, X-RateLimit-Limit, X-RateLimit-Remaining,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question