# Enable CORS in ASP.NET Core Web Api

No matter how many times I do this on my local machine I always forget how to enable CORS for "\*", just for testing something quick on my machine. This means that there's a proper way to do this and there's a **"I don't care how I do it, just stop my requests from returning CORS Error"**.


![CORS Error Dev Tools](https://cdn.hashnode.com/res/hashnode/image/upload/v1631651022109/8bMxrl6bdj.png)

The snippet below is for the latter, so it's just for development, but in the next few days I'll try to cover how to do this in production as well.

%[https://gist.github.com/thewindev/e1f12436b3de7964ccffd8dc23243328]


Basically, we do 3 things to enable CORS:

1. Create a policy with an arbitrary name
2. Configure that policy with the origins we want to allow (in my case, I use "*")
3. Enable CORS using for that policy
