CORS Error : How to add Access-Control-Allow-Origin for specific file type or file Ask

anwarjutt 11 Reputation points
2021-06-09T19:18:06.297+00:00

I don't want to allow Access-Control-Allow-Origin for everything on the site sipotek - just a couple of files, is there a way to do this?

Internet Information Services
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,715 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,036 Reputation points Microsoft Vendor
    2021-06-10T02:33:22.337+00:00

    Hi @anwarjutt

    You can use location element to set Access-Control-Allow-Origin for specific files, here is a Sample you can use as a reference:

    <location path="Sample.txt">  
        <system.webServer>  
          <httpProtocol>  
            <customHeaders>  
              <add name="Access-Control-Allow-Origin" value="*" />  
            </customHeaders>  
          </httpProtocol>  
        </system.webServer>  
      </location>  
    

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments