Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure CORS for Azure Functions Local Host

I'm testing an Azure Functions app locally with the Azure Functions CLI tooling. Is there any way I can configure CORS settings for the local host?

like image 418
Mark Heath Avatar asked Feb 21 '17 22:02

Mark Heath


People also ask

How do I enable CORS function in Azure?

To enable CORS support in Azure Functions is as simple as going to the CORS tab for your Function App in the portal and specifying the domains that are allowed to make calls to your Function.

How do I enable CORS policy in Azure API management?

Configure the cors policy in API Management for the following scenarios: Enable the interactive test console in the developer portal. Refer to the developer portal documentation for details. When you enable CORS for the interactive console, by default API Management configures the cors policy at the global scope.

What is local settings JSON in Azure function?

The local. settings. json file is where you can define the values for your project in your developer environment.


2 Answers

You can configure CORS in the local settings file local.settings.json:

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

Settings in the local.settings.json file are used only when you're running projects locally

like image 54
Leonardo Avatar answered Oct 03 '22 10:10

Leonardo


You can start the host like this

func host start --cors * 

You can also be more specific and provide a comma delimited list of allowed urls

More here: https://github.com/Azure/azure-webjobs-sdk-script/issues/1012

like image 23
ayls Avatar answered Oct 03 '22 08:10

ayls