I have a REST Service Service Service and an angular.js client. The network is hosted on a different port, then in the RESTS service.
Retrieving data using $ http does not work, but using $ resource does not work.
in the REST service, I set the following global headers:
GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, { "Access-Control-Allow-Headers", "X-Requested-With"} }
Now in angular.js I can successfully read methods using $ http, for example
$http({ method:'get', url:address, requesttype:'application/json' }).success(function(data) { $scope.ServiceStatus = data; });
but reading the same address with $ ressource my code for factory does not work:
myApp.factory('qaServiceStatus', function($resource){ return $resource('http://localhost:1338/api/status', {}, { query: {method:'GET', headers: {'Content-Type': 'application/json'}, params:{}} }); });
and I use it that way in the controller
$scope.RESTStatus = qaServiceStatus.get({});
error I get: Origin http://localhost:7000
not allowed by Access-Control-Allow-Origin.
and also XMLHttpRequest cannot load http://localhost/api/status
. Origin http://localhost:7000
not allowed by Access-Control-Allow-Origin.
what am I doing wrong?
I also tried changing the allowed source to the exact address, but this does not help