I would like to enable by EnableCors attribute my own "MyPolicy" for one controller and for the others I would like to use default policy. So in my configure services method I write
services.AddCors(options =>
{
options.AddPolicy(name: "MyPolicy",
builder => builder
.WithOrigins("http://localhost:3000")
.AllowCredentials()
.AllowAnyMethod()
.AllowAnyHeader());
options.AddDefaultPolicy(
builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
and than in Configure method I just call:
app.UseCors();
it does not work as I expected. It's only define DefaultPolicy and the only way to use "MyPolicy" is to use them as:
app.UseCors("MyPolicy");
But in this case default policy does not work. Is it possible to define own policies by AddPolicy and default policy by AddDefaultPolicy.