Answer the question
In order to leave comments, you need to log in
How to force Laravel to send correct headers for CORS?
I tried https://github.com/barryvdh/laravel-cors/ - but it somehow works strangely, sometimes it works, sometimes it doesn't work, and I can't grasp what it depends on, I crashed it for two hours.
Tried to send headers directly. For example:
return response()->json(['response' => 'no query given'])
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
No 'Access-Control-Allow-Origin' header
Answer the question
In order to leave comments, you need to log in
barryvdh/laravel-cors solves this 100% out of the box, you don't even need to configure anything.
If it doesn't help, then you did something wrong.
the full text of the error?
What version of laravel?
ServiceProvider registered if the version is old?
middleware from laravel-cors added to your routes?
What is laravel-cors config?
Did you create it at all? Did they change?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question