How to clear No 'Access-Control-Allow-Origin' header error with Azure App Service

Problem:

I get the following error when I try an use a WEB API deployed to Azure App Service Web App:

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Solution:

Enable Cross-Origin Resource Sharing (CORS) on your Azure App Service Web App.

Explanation:

  1. From the Azure Portal locate your App Service that is hosting your WEB API
  2. Click CORS
    image
  3. Enter the full URL of the site you want to allow to access your WEB API or * to allow all domains
  4. Click Save

Now you should be able to access your WEB API.

Add comment

Loading