question

azure-7678 avatar image
0 Votes"
azure-7678 asked Grmacjon-MSFT commented

azure appservice to angular application croos origin error

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-webapps
· 1
5 |1600 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.

Hi @azure-7678,


Checking in to see if the below response help answer your question. Please "Accept the answer" if the response helped you. This will help us and others in the community as well. Let us know if you have further questions.

Thanks,
Grace

0 Votes 0 ·

1 Answer

ryanchill avatar image
0 Votes"
ryanchill answered

Hi @azure-7678,

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.

5 |1600 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.