azure appservice to angular application croos origin error

azure 1 Reputation point
2021-07-14T16:19:54.183+00:00

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

Access to XMLHttpRequest at 'https://login.windows.net/697f3ewe-c321-4a9a-9090-ad61341e3ccb/oauth2/v2.0/authorize?response_type=code+id_token&redirect_uri=https%3A%2F%2Fentrustapitest.azurewebsites.net%2F.auth%2Flogin%2Faad%2Fcallback&client_id=dc54ca88-75e1-4249-a642-f792295f8b20&scope=openid+profile+email&response_mode=form_post&nonce=a66d843bb52c4db78726aede8d2da156_20210714162303&state=redir%3D%252Fapi%252Fsecrets' (redirected from 'https://entrustapitest.azurewebsites.net/api/values') 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
    2021-07-16T22:29:09.647+00:00

    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