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 Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,795 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 25,471 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.

    0 comments No comments