1

Tenho a seguinte requisição na API Google usando $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');

O problema é que retorna o erro:

XMLHttpRequest cannot load http://maps.googleapis.com/maps/api/distancematrix/json?origins=Porto%20Alegre&destinations=Sao%20Paulo&mode=driving&language=pt-BR&sensor=false. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 405.

Sei que é CORS ja tentei colocar este código no angular:

moduloVistoria.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);

Mas nada funciona. Meu backend é em PHP e já coloquei:

header("Access-Control-Allow-Origin: *");

Alguém pode me dizer o que pode estar ocorrendo ?

7

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .