I’m not sure if I understand correctly. Are you using https://my-server.com/branches/index and so on directly? With REST apps it should not be called like that, use HTTP methods only. But it’s strange that CORS filter doesn’t work in that case. I have never used it though.
@Bizley Actually, I am still on my local server. using HTTPS or HTTP has no effect on CORS policy, it works on postman and also my custom action works fine ( actionTest() in the above controller in the frontend).
In this case, CORS filters work for actions that are already in the controller (like actionTest()). I think I have to send CORS header in every request using beforeAction
‘on beforeAction’ => function ($event) {
// send CORS headers here
},
That’s the thing - it should be done with this filter already here. But it makes me wonder because addCorsHeaders() there adds headers only when there are some in the first place, maybe this is the reason. Could you check it on your app?
Thanks for your time and for helping me.
I didn’t understand what you meant by the word “first place” and what to check.
the file Cors.php is completely identical to mine.
can you take a look at this
I want to try to add CORS header in ‘on beforeAction’, but I don’t know how. Can you help?
Debug your app and see if by the time the $this->addCorsHeaders($this->response, $responseCorsHeaders); is called in that filter, there are any headers already registered.