I've deployed my MVC5 app to IIS and one of the methods on my controllers returns a json object. The app works fine when I browse to the site. I can see the json object in my browser if I call the method on the controller directly.
But now I am building an Aurelia app and doing a fetch on the api method. In Chome, with developer tools, under Console, I get an the following error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:55829' is therefore not allowed access.
Anything I need to do to my hosting application's web.config?
This is how I am calling the method from Aurelia:
http.fetch('http://localhost/MyCart/Home/GetProducts')
.then(result => result.json())
.then(data => {
console.log(data.description);
});
I got it working by enabling CORS on my hosted app's web.config:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>