ozee31 / cakephp-cors

A CakePHP (3.3+) plugin for activate cors domain in your application
MIT License
43 stars 31 forks source link

Headers not present at `POST` #15

Closed bobmulder closed 5 years ago

bobmulder commented 6 years ago

I've added your plugin as documented. The OPTIONS call goes well, however the POST call doesn't work. It will return a 200 but I get the message: Failed to load {myapiurl}: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.. It seems the CORS hearders are missing in my POST call:

OPTIONS call: schermafbeelding 2018-06-14 om 13 35 25

POST call: schermafbeelding 2018-06-14 om 13 35 42

I can't find any issues in your code. Any hints?

Kind regards,

Bob

bobmulder commented 6 years ago

It seems #7 has something to do with it...

ozee31 commented 6 years ago

I don't have that problem.

When I send a post request on a valid route :

success

When I send a post request on a route where I throw an exception :

error

And When I send a post request on a route that doesn't exist :

notexist

bobmulder commented 6 years ago

I figured out that the cors-related headers won't be added when an exception is thrown. I guess #7 is related to my issue

ozee31 commented 6 years ago

Yes i look this Pull Request ASAP

ozee31 commented 6 years ago

PR merged, it's ok for you?

leonardomrl commented 6 years ago

I have the same problem :(

ozee31 commented 6 years ago

Do you use special plugins or components?

leonardomrl commented 6 years ago

It worked out my problem, the error was not in CORS, it's working perfectly for me