Allow CORS: Access-Control-Allow-Origin not working

Joe Green 146 Reputation points
2022-01-06T18:45:47.43+00:00

I have IIS 8.5 running on Win 2012 R2 server. I installed CORS module from here https://www.iis.net/downloads/microsoft/iis-cors-module. Created a web.config file with this

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
    <cors enabled="true" failUnlistedOrigins="true">
        <add origin="*" />
    </cors>
   <httpProtocol>
     <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>

In IIS Manager, under HTTP Response Headers, I added Access-Control-Allow-Origin with a value of *.

Still I'm getting the CORS error - Access to XMLHttpRequest at 'https://google.com' from origin 'http://mysite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

What am I doing wrong?

Joe

Windows development Internet Information Services
{count} votes

1 answer

Sort by: Most helpful
  1. Couch 1 Reputation point
    2022-07-05T18:42:28.617+00:00

    @Sam Wu-MSFT The config you have posted does not work. Still the same same error. I have tried all in this document cors-module-configuration-reference

    But still receiving the same same error as @Joe Green
    Any suggestions?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.