title: Azure API - How do I setup CORS
body: <p>I have REST API, that is hosted in Azure. If I make request in interactive console with GET method  ('/api/pets'), request goes through just fine. But when I make POST request (POST '/api/pets'), CORS error appears.</p>
  <p>Response in interacive console throws this error:
  <a href="https://i.stack.imgur.com/IxlOz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IxlOz.png" alt="Response in interacive console throws this error" /></a></p>
  <p>startup.cs</p>
  <pre class="lang-cs prettyprint-override"><code>        public void ConfigureServices(IServiceCollection services)
          {
          
              .
              .
              .
  
              services.AddCors(options =&gt; options.AddPolicy(&quot;CorsPolicy&quot;,
                  builder =&gt;
                  {
                      builder
                          .AllowAnyOrigin()
                          .AllowAnyHeader()
                          .AllowAnyMethod();
                  }));
              .
              .
              .
          }
  
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
  
              app.UseCors(&quot;CorsPolicy&quot;);
              .
              .
              .
          }
  </code></pre>
  <p>All API's CORS policy</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;policies&gt;
      &lt;inbound&gt;
          &lt;cors&gt;
              &lt;allowed-origins&gt;
                  &lt;origin&gt;*&lt;/origin&gt;
              &lt;/allowed-origins&gt;
              &lt;allowed-methods preflight-result-max-age=&quot;300&quot;&gt;
                  &lt;method&gt;GET&lt;/method&gt;
                  &lt;method&gt;POST&lt;/method&gt;
                  &lt;method&gt;PUT&lt;/method&gt;
                  &lt;method&gt;DELETE&lt;/method&gt;
                  &lt;method&gt;HEAD&lt;/method&gt;
                  &lt;method&gt;OPTIONS&lt;/method&gt;
                  &lt;method&gt;PATCH&lt;/method&gt;
                  &lt;method&gt;TRACE&lt;/method&gt;
              &lt;/allowed-methods&gt;
              &lt;allowed-headers&gt;
                  &lt;header&gt;*&lt;/header&gt;
              &lt;/allowed-headers&gt;
              &lt;expose-headers&gt;
                  &lt;header&gt;*&lt;/header&gt;
              &lt;/expose-headers&gt;
          &lt;/cors&gt;
      &lt;/inbound&gt;
      &lt;backend&gt;
          &lt;forward-request /&gt;
      &lt;/backend&gt;
      &lt;outbound /&gt;
      &lt;on-error /&gt;
  &lt;/policies&gt;
  </code></pre>
  <p>I also tried setting CORS policy on azure portal only in specific API, but it doesn't work
  Everything works fine locally.</p>