[Django]-Blocked by CORS policy : No 'Access-Control-Allow-Origin' header is present on the requested resource

4👍

You could use iis response header:

1)open iis manager and select the site.

2)Double-click HTTP Response Headers from the middle pane.

enter image description here

3)In the actions pane, click Add.

enter image description here

4)In the Name box, type the custom HTTP header name.
In the Value box, type the custom HTTP header value.

below is header and value:

Access-Control-Allow-Origin:*

Access-Control-Allow-Headers: Content-Type

Access-Control-Allow-Methods:GET,POST,PUT,DELETE,OPTIONS

Access-Control-Allow-Credentials: true

5)Click OK.

enter image description here

or you can directly add below code in the web.config file:

<system.webServer>
      <httpProtocol>
        <customHeaders>
          <add name="Access-Control-Allow-Origin" value="*" />
          <add name="Access-Control-Allow-Headers" value="Content-Type" />
          <add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS" />
         <add name="Access-Control-Allow-Credentials" value="true" />
        </customHeaders>
      </httpProtocol>
  </system.webServer>

0👍

Use this command in run (windows key + r) and run your app in the new browser

chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security

I hope it works as you want

Leave a comment