I'm developing an application with angular, and I'm having a problem with the ngResource module.
I need to call a URL from another system, so I've already added the required headers in the other application. However in my request I need to call using a Content-type: application / x-www-form-urlencoded , for this I changed the save method of $ resource. More when I make the change it stops doing the requests in CORS and presents the error below.
In 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access.
This error only appears when I change the headers of the save method below the way I'm changing.
$resource(config.url.generalSystems + '/index.php',{},{save:{headers: {'Content-Type': 'application/x-www-form-urlencoded'}, method: 'POST'}}).save("Action=Login&validator=&RequestedURL=&Lang=pt_BR&TimeOffset=&User="+Login+"&Password="+Senha, function (retorno) {
console.log(retorno);
}
Below is the code that works with CORS, but it does not send the Content-type: application / x-www-form-urlencoded json , and can not because it is not compatible with the other application.
$resource(config.url.generalSystems + '/index.php').save({Action : 'Login', validator : '', RequestedURL : '', Lang : 'pt_BR', TimeOffset : '', User : Login, Password : Senha}, function (retorno) {
console.log(retorno);
}
What do I need to do to make CORS work in the first example?
Access-Control-Allow-Origin: * / * and Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept