lundi 18 avril 2016

XMLHttpRequest - Response to preflight request doesn't pass. Origin header is set

Here is the error:

XMLHttpRequest cannot load 'url here'. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

Here is a wireshark follow:

OPTIONS /api/v1/solo/players HTTP/1.1 Host: 'url here' Connection: keep-alive Cache-Control: max-age=0 Access-Control-Request-Method: GET Origin: http://localhost:4200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2711.0 Safari/537.36 Access-Control-Request-Headers: accept, apikey Accept: */* Referer: http://localhost:4200/ Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8

HTTP/1.1 200 OK Date: Tue, 19 Apr 2016 00:46:46 GMT Server: Apache X-Powered-By: PHP/5.6.18 Access-Control-Allow-Methods: GET, POST, OPTIONS Access-Control-Allow-Orgin: * Access-Control-Allow-Headers: accept, apikey Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8

I am attempting to build an Ember application and I have a back-end API that can preform GET requests to return data. I simply have no idea why I am still getting a No Access-Control-Allow-Origin error as it is clearly present in the wireshark report.




Aucun commentaire:

Enregistrer un commentaire