<p>There's plenty of help with configuring CORS when running an Azure Functions app in local dev or inside Azure on the web.</p>

<p>But we're currently hosting the functions in our own Kubernetes cluster, and I've tried setting an environment variable 'Host' to '{"CORS":"*"}', which is what it looks like Azure does, but this doesn't seem to have added the CORS headers.</p>

<p>Is this because it ignores the environment variable if its not hosted locally or in Azure? In which case, do I need to be running in production with <code>func</code> so I can pass the allowed origins parameters to the commandline app? (The Dockerfile MS give you uses <code>dotnet</code> with the <code>WebHost.dll</code> - and I'm not sure where to find options for that command).</p>

<p>I've made a similar for response for Raspberry Pi in <a href="https://stackoverflow.com/a/54304478/10417839">another SO post</a> which is applicable here too.
Here is the same answer for reference</p>

<p>CORS is basically just sending the appropriate headers in your response.</p>

<p>On Azure, this is taken care of by the platform itself but since you will be running/accessing the functions runtime directly from a container, you can just set them on the response object.</p>

<p>For example, if you are using NodeJS/JavaScript for your functions, set the headers using context.res</p>

<pre><code>context.res = {
  status: 200,
  headers: {
    'Access-Control-Allow-Credentials': 'true',
    'Access-Control-Allow-Origin': '*', // Or the origins you want to allow requests from
    'Content-Type': 'application/json'
  },
  body: {
    just: 'some data'
  }
};
</code></pre>

<p>Also, another way to do CORS is using a reverse proxy that adds the headers for you, especially makes things easier if they are the same for all your functions.</p>
