title: .NET Core 2.0 - Still seeing No 'Access-Control-Allow-Origin' header error
body: <p>I'm at wit's end on this one. I've already researched other answers to similar questions on SO w/o any luck.</p>
  
  <p>I'm fairly certain I've got CORS enabled correctly to allow incoming requests (in this case, POST requests) from all origins, but I'm seeing the error below:</p>
  
  <blockquote>
    <p>Failed to load <a href="http://localhost:5000/expenses" rel="noreferrer">http://localhost:5000/expenses</a>: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://localhost:4200" rel="noreferrer">http://localhost:4200</a>' is therefore not allowed
    access. The response had HTTP status code 500.</p>
  </blockquote>
  
  <p>Here's how I've enabled CORS in my webAPI project:</p>
  
  <p><strong>relevant methods in Startup.cs</strong></p>
  
  <pre><code> // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddCors();
              services.AddMvc();
  
              services.AddDbContext&lt;ExpensesDbContext&gt;(options =&gt;
                                                      options.UseMySQL(Configuration.GetConnectionString("DefaultConnection")));
              services.AddTransient&lt;IBaseDa&lt;Accounts&gt;, AccountsDataAccess&gt;();
              services.AddTransient&lt;IExpensesDa, ExpensesDa&gt;();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
              env.EnvironmentName = "Development";
  
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
  
              app.UseCors(builder =&gt; builder
                          .AllowAnyHeader()
                          .AllowAnyMethod()
                          .AllowAnyOrigin()
                          .AllowCredentials());
  
              app.UseMvc();
          }
  </code></pre>
  
  <p>If i'm using <code>.AllowAnyOrigin()</code> and <code>.AllowAnyMethod()</code>, why am I seeing the error above?</p>