title: Use Cors based on an appSettings in .Net Core
body: <p>I am updating a .net 4.5.2 project to .Net core web api. Right now, the Cors is setup as below based on an appSetting value <code>CorsAllowAll</code>:</p>
  
  <pre><code>if ((ConfigurationManager.AppSettings["CorsAllowAll"] ?? "false") == "true")
  {
      appBuilder.UseCors(CorsOptions.AllowAll);
  }
  else
  {
      ConfigureCors(appBuilder);
  }
  
  private void ConfigureCors(IAppBuilder appBuilder)
  {
      appBuilder.UseCors(new CorsOptions
      {
      PolicyProvider = new CorsPolicyProvider
      {
          PolicyResolver = context =&gt;
          {
             var policy = new CorsPolicy();
             policy.Headers.Add("Content-Type");
             policy.Headers.Add("Accept");
             policy.Headers.Add("Auth-Token");
             policy.Methods.Add("GET");
             policy.Methods.Add("POST");
             policy.Methods.Add("PUT");
             policy.Methods.Add("DELETE");
             policy.SupportsCredentials = true;
             policy.PreflightMaxAge = 1728000;
             policy.AllowAnyOrigin = true;
             return Task.FromResult(policy);
          }
      }
      });
  }
  </code></pre>
  
  <p>How can I achieve the same in .net core? Unfortunately, I won't be knowing the URLs of each environment. But I do know that for Local, DEV and QA environments, the appSetting <code>CorsAllowAll</code> is true. But the UAT and PROD environments it would be false.</p>
  
  <p><strong>UPDATE</strong>
  My appSettings.json is like below:</p>
  
  <pre><code>"AppSettings": {
      ...
      "CorsAllowAll": true 
      ...
    }
  </code></pre>