question

VigneshArvind-2509 avatar image
0 Votes"
VigneshArvind-2509 asked ·

I'm getting CORS issue while accessing font files from another Azure Web App

Access to font at 'https://example1.azurewebsites.net/css/fonts/font-icons.woff' from origin 'http://example2.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


Actually example1.azurewebsite.net has some css, images etc...
i'm trying to use this URL to example2.azurewebsites.net for fetching those files.

azure-webapps
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SnehaAgrawal-MSFT avatar image
0 Votes"
SnehaAgrawal-MSFT answered ·

Thanks for asking question! Missing CORS errors occur when there is no access-control-allow-origin header present in responses from separate domains than your root page source. If you're using a .NET application to send the request to your API, add the following to your web.config. You may need to add additional headers such as Access-Control-Allow-Methods and Access-Control-Allow-Headers based on what requests you're making against your API.

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


You may refer to this SO issue.

Some additional links might be helpful: https://docs.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-3.1


[1]: /answers/storage/attachments/4561-2020-03-16-12-39-26-getting-access-control-allow-o.png


· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

VigneshArvind-2509 avatar image
0 Votes"
VigneshArvind-2509 answered ·

@SnehaAgrawal-MSFT

im using .NET Core as API and Front-End in Angular.....so do i need to add these "Access-Control-Allow-Origin" in the config file of .NET Core ??

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the clarification! Also could you please make sure if you have enabled CORS?


0 Votes 0 · ·