vendredi 29 juillet 2016

FOSRest OPTIONS request return 405 Method Not Allowed

I wrote a REST services with Symfony FOSRestBundle. It work fine with GET request.

Now, I am trying to access with Ember « models" and I get an error message. Indeed, Ember try to access with OPTIONS request (preflight) and It failed with « Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response ». I tried to access the REST service with Postman and I got this error : with OPTIONS http://ift.tt/2ajnz3k : "405 Method Not Allowed »

but it works fine if I call OPTIONS http://myUrl.local/

I use apache under El Capitan (IMac). I tried to append these lines to /private/etc/apache2/extra/httpd-default.conf : Header add Access-Control-Allow-Origin "*" Header add Access-Control-Allow-Headers "origin, content-type" Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

I tried to append these lines in directive in my VirtualHost. Same results in both case.

Is the problem in Symfony or FOSrestBundle.

I need help to understand what is happening. How I can resolve my problem.




Aucun commentaire:

Enregistrer un commentaire