Atharane
Atharane

Reputation: 84

CORS error while fetching data from Azure Function API

I have created an Azure Function API by following https://learn.microsoft.com/en-us/azure/developer/javascript/tutorial/azure-function-cosmos-db-mongo-api?tabs=visualstudiocode tutorial, but whenever I try posting data to it via my react-app using

axios.post(url, postData)

I get CORS errors, do I need to change anything in index.ts in my API folder?

Upvotes: 2

Views: 1653

Answers (1)

Vishal Siddula
Vishal Siddula

Reputation: 66

If you're running the function app locally, there's an option to configure CORS in local settings file local.settings.json

{
  "Values": {
  },
  "Host": {
    "CORS": "*"
  }
}

For the function app in azure, configure CORS policies in portal.

enter image description here

Upvotes: 4

Related Questions