DEV Community

Cover image for Enable cross-origin resource sharing (CORS) in IIS
Adam K Dean
Adam K Dean

Posted on

1 2

Enable cross-origin resource sharing (CORS) in IIS

If you're hosting your API on a different domain to your app, such as api.domain.com, you may be hitting into some cross-origin request roadblocks. In IIS, this is pretty easy to fix -- or well -- disable.

In your WebAPI project's web.config, put in the following:

<httpProtocol>
    <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
    </customHeaders>
</httpProtocol>

This will enable cross-origin resource sharing (CORS) and allow you to get back to work.

Top comments (1)

Collapse
 
nandha6202 profile image
Nandhakumar R

Hi, I am facing the Cors issue with the build file used in IIS. Can you provide a good JS framework for building the NodeJS project?

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post