title: CORS issue: Angular 5 on AWS S3 & Cloudfront and .net core webapi on IIS10 EC 2 windows server 2019
body: <p>I am getting following error while accessing Angular app through browser (chrome/Edge/Firefox/Opera). <em><strong>API request works on direct calls from well through Postman/Fiddler.</strong></em></p>
  <p>So i think there something between Cloudfront and EC2 calls and CORS policy</p>
  <p><a href="https://i.stack.imgur.com/hsxeF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hsxeF.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/TD3qQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TD3qQ.png" alt="enter image description here" /></a></p>
  <p>Following is my set up.</p>
  <p><em><strong>Angular Setup:</strong></em></p>
  <ul>
  <li>S3 Bucket with Public access Policy</li>
  <li>Cloudfront with Behavior whitelisting Headers</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/JTbgd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JTbgd.png" alt="enter image description here" /></a></p>
  <p><em><strong>.netcore web api setup:</strong></em></p>
  <ul>
  <li>EC 2 instance with Windows Server 2019</li>
  <li>IIS 10 website with following httpresponse headers added  SSL implemented
  <a href="https://i.stack.imgur.com/nlt0h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nlt0h.png" alt="enter image description here" /></a></li>
  <li>As required I have addred CORS policy in .net core application as follows</li>
  </ul>
  <pre><code>    services.AddCors(options =&gt;
              {
                  options.AddPolicy(&quot;EnableCORS&quot;, builder =&gt;
                  {
                      builder.AllowAnyOrigin()
                          .AllowAnyHeader()
                          .AllowAnyMethod()
                          .AllowCredentials();
                  });
              });
  </code></pre>
  <p>added CORS middleware</p>
  <pre><code>     app.UseCors(&quot;EnableCORS&quot;);
  </code></pre>
  <p>Have added required Annotation over <strong>APi Controllers</strong></p>
  <pre><code>     [EnableCors(&quot;EnableCORS&quot;)]
  </code></pre>
  <p>Not sure what am i missing along this setup.</p>