Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable CORS on IIS Manager of Windows 10?

Tags:

cors

windows

iis

I've created an HTTPS server using IIS Manager (Windows 10). Now, I want this server to support CORS requests.

I've read some information. For example, this link says that I have to create a file web.config in the directory. Unfortunately, it didn't work out. This link says that I should edit some config files, but I don't find them on my machine.

like image 312
CrazySynthax Avatar asked Jun 28 '17 12:06

CrazySynthax


People also ask

How do I enable CORS in IIS?

Right click the site you want to enable CORS for and go to Properties. Change to the HTTP Headers tab. In the Custom HTTP headers section, click Add. Enter Access-Control-Allow-Origin as the header name.


1 Answers

I had a similar issue recently. Most tutorial/documentation only suggests adding custom headers in the configuration. But this does not tell IIS to handle the CORS Pre-flight request by itself.

To do so, you must install the CORS Module in IIS and add some configuration in the web.config file, as explained here: IIS CORS module Configuration Reference

I recently used this to Reverse Proxy to a REST API and handling the CORS only in IIS so that I don't have to rebuild my project to change CORS settings.

like image 129
Joel Bourbonnais Avatar answered Sep 24 '22 00:09

Joel Bourbonnais