Use the UseCors()
extension method on the IApplicationBuilder
in the Configure
method to apply the CORS policy to all requests.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddCors();
}
public void Configure(IApplicationBuilder app)
{
// Other middleware..
app.UseCors(builder =>
{
builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
// Other middleware..
app.UseMvc();
}