Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular.js chrome Access-Control-Allow-Origin

Tags:

angularjs

I'm trying to use an Angular.js service to get a JSON from my REST service made with Jersey/Spring.

When i'm using firefox, it works fine, but when i go to Chrome i got the message:

XMLHttpRequest cannot load http://localhost:8080/VirtualLawyerPj/services/timeoftheday/asjson/tue. Origin http://localhost:8090 is not allowed by Access-Control-Allow-Origin.

Here's my service code:

angular.module('myAppServices', ['ngResource']).
factory('Time', function($resource){
    return $resource('http://localhost:port/VirtualLawyerPj/services/timeoftheday/asjson/tue',{port:":8080"}, {
        query: {method:'GET', params:{}, isArray:false}
    });
});

Someone had the same problem? How did you got this working?

Thanks.

like image 463
Leonardo Frangelli Avatar asked Oct 01 '12 21:10

Leonardo Frangelli


1 Answers

The CORS solution is described at html5rocks tutorial. Worked for me.

like image 120
Greg Dan Avatar answered Sep 18 '22 18:09

Greg Dan