title: Access to XMLHttpRequest at 'URL' from origin 'http://localhost:4200' has been blocked by CORS policy:
body: <p>I thought I'd allowed access to all origins but I'm still getting this error.</p>
  <blockquote>
  <p>Access to XMLHttpRequest at 'localhost:60248/api/page/1' from origin
  'http://localhost:4200' has been blocked by CORS policy: Cross origin
  requests are only supported for protocol schemes: http, data, chrome,
  chrome-extension, https.</p>
  </blockquote>
  <p><strong>UPDATE</strong> the error has now changed after adding suggested code changes. It's now as follows:</p>
  <blockquote>
  <p>Access to XMLHttpRequest at 'http://localhost:60248/api/page/1' from
  origin 'http://localhost:4200' has been blocked by CORS policy:
  Response to preflight request doesn't pass access control check:
  Redirect is not allowed for a preflight request.</p>
  </blockquote>
  <p>In Startup.cs I have this:</p>
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddCors(options =&gt;
          {
              options.AddPolicy(name: &quot;AllowAll&quot;,
                  builder =&gt;
                  {
                      builder.AllowAnyOrigin()
                          .WithMethods(&quot;PUT&quot;, &quot;DELETE&quot;, &quot;GET&quot;);
                  });
          });
  </code></pre>
  <p>In my controller I have this:</p>
  <pre><code>[Route(&quot;api/[controller]&quot;)]
  [ApiController]
  public class PageController : ControllerBase
  {
      ...
  
      [EnableCors(&quot;AllowAll&quot;)]
      [HttpGet(&quot;{id:int}&quot;)]
      public async Task&lt;IActionResult&gt; GetPageData(int id)
      {
         ...
  </code></pre>
  <p>This is the Angular service that calls the endpoint:</p>
  <pre><code>export class PageContentService {
    constructor(private http: HttpClient) { }
  
    getContent(id: number): Observable&lt;PageContent&gt; {
  
      let headers = new HttpHeaders();
      headers = headers.set('Content-Type', 'application/json');
      const httpOptions = {
        headers: headers
      }
  
      return this.http.get&lt;PageContent&gt;(`http://localhost:60248/api/page/${id}`, httpOptions);
    }
  }
  </code></pre>
  <p>I thought that would take care of it, but clearly not.</p>
  <p>What else do I need to do?</p>