HI I have an Angular Aplication that consume from a REST API in NodeJS both are deploy in IIS server, from Node I am using IISNode.
I am getting the error XMLHttpRequest cannot load http://181.49.53.186:8006/DynamicContent/form/list. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://web.procesosyservicios.info:3006' is therefore not allowed access.
only in production version in developer version never get the error. The strange is that no get the error always for example with the previous method I get the error only 2 o 3 times for each 10 calls.
My app.js file have the following configuration:
router.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST');
res.header('Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Authorization');
next();
});
Alternative I delete the previous lines and define the same in my web.coonfig file like this:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,POST" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With,content-type,Authorization" />
</customHeaders>
</httpProtocol>
but the result is the same only work sometimes. I don't have idea about what can be the error.
thanks for the help
SOLUTION
In my case the solution was change my web.config file following this configuration and adding this lines:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,POST" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With,content-type,Authorization" />
</customHeaders>
</httpProtocol>