I have the following request in the Google API using $ http AngularJS:
$http.get('http://maps.googleapis.com/maps/api/distancematrix/json?origins=Porto Alegre&destinations=Sao Paulo&mode=driving&language=pt-BR&sensor=false');
The problem is that it returns the error:
XMLHttpRequest can not load link . In 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access. The response had HTTP status code 405.
I know it's CORS already tried to put this code in the angle:
moduloVistoria.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);
But nothing works. My backend is in PHP and I've already put it:
header("Access-Control-Allow-Origin: *");
Can anyone tell me what might be happening?