I know there are tons of information about CORS but there are so many that I can't find what I need. I'm building a Cordova APP and I'm calling Google Maps Distance API to get the distance between two points. But when I called it using $resourse I get CORS error.
error:
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:8000' is therefore not allowed access.
My factory
function googleMapsApi($resource, API_KEY_WIN,DIST_URL_WIN){
var url = DIST_URL_WIN+mylat+','+mylng+'&destinations='+lat+','+lng+'&key='+API_KEY_WIN;
console.log(url);
var result = $resource(url, {}, {get: {
method: 'GET',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS, DELETE, PUT',
'Access-Control-Allow-Headers': 'Origin, Content-Type, Accept, Authorization, X-Request-With, X-CLIENT-ID, X-CLIENT-SECRET',
'Access-Control-Allow-Credentials': true
}
}
});
return result;
}
What am I doing wrong? Note: Installing Chrome's plugin won't solve my problem.