I've been struggling with CORS for a substantial amount of time, and still no closer to a full understanding.
My simplest example is using Wunderlist API -
Using the below code:
var settings = {
"async": true,
"crossDomain": true,
"url": "http://a.wunderlist.com/api/v1/lists",
"method": "GET",
"headers": {
"x-client-id": "{ID}",
"x-access-token": "{TOKEN}",
"cache-control": "no-cache"
},
"data": "{\n\t\"revision\": 1,\n\t\"completed\": true\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Within Postman/Fiddler will return results. However, throwing it onto a basic site, or Codepen will either return a 405
, a Pre-flight Warning
or an Invalid Request
I've loosely come to the understanding that you allow it within your server side, but I have to assume that not every single site out there allows for Postman etc to connect, nor for every vendor I sign up with it allow my domain.
How is it you work on bypassing the CORS Compliance within an API Call then? I've tried a lot of things I've read, including crossDomain, Cross-Origin Header, etc and always get same result.
Any insight?