0
I’m using the angular $http to make REST calls on my server, but I’m having a problem:
No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'null' is therefore not allowed access.
I’ve tried a lot of things, but nothing’s solved me yet, someone knows how to fix?
My Code:
.factory('CotacaoService', ['$http', function($http){
var cotacao = [];
$http({
method: 'GET',
url: 'http://192.168.254.8:8084/CotacaoREST/recursos/cotacoes/1/991'
}).then(function successCallback(response) {
cotacao = response.data;
}, function errorCallback(response) {
console.log(response);
});
return cotacao;
}]);
What are you using in the backend? Springrest, Jersey? What technology?
– josivan
I’m wearing Jersey
– Geferson
I do not know deeply the Jersey. In the case of Spring the note
org.springframework.web.bind.annotation.CrossOrigin
resolve. By quickly searching I found something talking to include in the Response header the following attribute:"Access-Control-Allow-Origin", "*"
. See if this link help you.– josivan
You are testing in the browser or in an emulator?
– André Vicente
josivan valeu, I will test with this example. Andre, I am testing in browser, Chrome Console or Firefox returns me this error
– Geferson
In the browser you have to give a command to enable. I’m doing a project also that only scrolls in the emulator or the device itself, in Chrome and firefox the same error. You have some tips on this link http://stackoverflow.com/questions/4819060/allow-google-chrome-to-use-xmlhttprequest-to-load-a-url-from-a-local-file
– André Vicente
I did the tests here with the change in jersey and running this command on Chrome and still gives the same problem, I was even looking at a tutorial to add three parameters in the header, and also did not work, the strange thing is that only happens with the angle, I have an android project that consumes the webservice and works normal, someone has some idea?
– Geferson