I'm trying to do a call to a service from an angular site but for some reason I'm getting an anoying CORS error. It's weird because I can do the call from my local machine, but when I deploy the code into my server I get the error executing the same call.
Could someone explain me why this is happening?
Call from Angular:
var externalURL = 'https://www.someDomain.com/service';
this.http.get(externalURL).toPromise()
.then((response: any) => {
//some stuff
})
.catch(err => {
console.error(err);
});
When I execute this call from my local machine or even if I paste the url in the browser, the call works fine. But when I upload the code to my production server, the cors errors appears.
if I'm not wrong a Cors error happens because the following:
-The client side (a web page) try to call the server side -The server check if the request has a permission to access him, and if not he block the client. -The client get CORS error because of the server block.
Above has sense for me, expects because I'm able to do the call from my local machine.
How can I fix that problem?
Thanks in advance!!