Wednesday, July 6, 2022

Resolving CORS errors when calling Azure Function from Azure Static Web App

We encounter Cross-Origin Resource Sharing (CORS) errors when we call an API from another domain if proper policies are not allowed.

In order to resolve the issue we need to allow the calling domain in our API. In this instance it is an Azure Function.

Following are the steps to resolve the error

1. Navigate to Azure Function and navigate to the CORS blade in API section

2. Then specify the calling application URL in Allowed Origins section. In this instance it is the Azure static web app I'm using.

Now I'm able to connect to the API which is an azure function app with SignalR output binding

No comments: