I encountered an issue while using ngResource to call a REST API hosted on Amazon Web Services:
Upon making the request to , I received the following error message: "XMLHttpRequest cannot load. 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' is therefore not allowed access. Error 405
The service setup:
socialMarkt.factory('loginService', ['$resource', function ($resource) {
var apiAddress = "http://server.apiurl.com:8000/s/login/";
return $resource(apiAddress, {
login: "facebook",
access_token: "@access_token",
facebook_id: "@facebook_id"
}, {
getUser: {
method: 'POST'
}
});
}]);
Related controller code snippet:
[...]
loginService.getUser(JSON.stringify(fbObj)),
function (data) {
console.log(data);
},
function (result) {
console.error('Error', result.status);
}
[...]
I'm running this in Chrome. Any suggestions on how I can resolve this issue apart from configuring the server to accept headers from origin localhost
?