I'm trying to read with an AngularJS / Phonegap application an HTTPS address that returns me a JSON ( link ). I'm getting this error:
XMLHttpRequest can not load link . Response to preflight request does not pass access control check: In 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access. The response had HTTP status 404.
angular.js:14700 Possibly unhandled rejection: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, X-Requested-With","Access-Control-Allow-Credentials":true,"Accept":"application/json, text/plain, */*"},"url":"https://gestormegaclube.com.br/api/app/v1/parceiros"},"statusText":"","xhrStatus":"error"}
I think this is not a block on the server because, using PostMan ( link ) it returns me the information, I already used several header different and nothing works.
.controller('MainController', function($scope, $http){
$http.get("https://gestormegaclube.com.br/api/app/v1/parceiros", {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, X-Requested-With',
'Access-Control-Allow-Credentials': true
}
}).then(function(response) {
$scope.data = response.data;
});
});
Maybe it's because I'm in localhost, does anyone know how to get around this?