A quick post to give an insight on a non expected problem most likely you will stumble across when you start creating a little web app using your favorite web app framework and and ASP.NET Core web service running in your localhost. It also seemed to be a common question on the internet, but I could not find the exact answer.

Setup

Symptom

I the error message in Chrome is:

FireFox is:

And in Edge is:

Solution

Solution lies at the server side. My rest api is built using ASP.NET Core 2.1. So the server needs to know how to handle requests from differnet origins. Probably my lack of knowledge with CORS in practise is the reason of finding a lot of misleading answers on the web.

Extras

During development there is a workaround by disabling CORS on the web browser itslef. If you use Google Chrome run it with the command line argument “–disable-web-security”, or if you debug you develop your JS application with VS Code add it to launch.json:

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *