azure appservice to angular application croos origin error

azure 1 Reputation point

azure web api app service getting cross error while connecting to angular.

Access to XMLHttpRequest at '' (redirected from '') from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Azure App Services
Azure App Services
A feature of Azure App Service used to create and deploy scalable, mission-critical web apps.
4,559 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 16,526 Reputation points Microsoft Employee

    Hi @azure ,

    You need to add CORS to your API app service either through the portal or running the CLI command az webapp cors add --resource-group myResourceGroup --name <app-name> --allowed-origins 'http://localhost:4200'. After you deploy your angular app, you will want to either add the URL of the app or '*' to the allowed origins.