I have been developing an Angular JS application that talks to PHP/Apache web service.
So far it has been working fine for POST and GET requests, but for PUT I have the following error
Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.
I have tested the API with Postman and it works just fine
Any idea to solve my issue? Thanks
Note that the API server, Apache has the following config already
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
Options All
AllowOverride All
Allow from all
And Chrome has this response header
HTTP/1.1 200 OK
Date: Mon, 15 Feb 2016 02:52:56 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.14
Allow: GET,HEAD,PUT,PATCH,DELETE
Cache-Control: no-cache
Set-Cookie: laravel_session=eyJpdiI6IldvM3Z5eUpKcUI5Q0RXam5UN283TEE9PSIsInZhbHVlIjoiV3FnTVpUcFliWjZvczFrM2VuYXpBamI5NmIwR24rdThPWGRuMUZjbjd5K0I2N3F1REp4ZFJVc3U3QnhCZmxmZ0ZONDU4SEVtWm42SUVEWmJhRmF6M1E9PSIsIm1hYyI6ImMzOTVlNDZhZmNjYWNlM2I1N2FjYjQ4N2FhZDc5ZWY2MWJhYTdiNDBlMWExMGJkYzczYzE1MTczMzAyYzVkMjEifQ%3D%3D; expires=Mon, 15-Feb-2016 04:52:56 GMT; Max-Age=7200; path=/; httponly
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Apologies, this matter has been since solved for a while now. It's actually rather stupid mistake. If I'm not wrong it's because the API side there was a typo on of the parameters
The pre flight error message on Chrome was arguably misleading
Check your variables if you have similar error like me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With