Reputation: 84
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
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.
Upvotes: 4