On ASP.NET Core 1.1.
I included the nuget package Microsoft.AspNetCore.Cors" Version="1.1.2
.
Startup.cs
has CORS code shown below.
These are the issues:
Issue 1: as per the below code CORS has been configured to allow only 'POST' but it allows ALL http methods not restricting only to 'POST'
Issue 2: CORS has been configured only to allow "CustomHeader1", "CustomHeader2" but NOT allowing any request headers including valid "CustomHeader1", "CustomHeader2" request headers. If I remove headers altogether in the request then only receiving response.
Code:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddCors();
}
public void Configure(IApplicationBuilder app)
{
app.UseCors(builder => builder
.AllowAnyOrigin()
.WithMethods("POST")
.WithHeaders("CustomHeader1", "CustomHeader2")
);
}
What I'm missing to configure CORS only for POST method & to allow only "CustomHeader1", "CustomHeader2" in the request?