Open pkskelly opened 2 years ago
See Enable Cross-Origin Requests (CORS) in ASP.NET Core to enable Dev/Prod settings using multiple policies. Similar to below create Policies that can be applied based on the Environment.
builder.Services.AddCors(options =>
{
options.AddPolicy("Policy1",
builder =>
{
builder.WithOrigins("http://example.com",
"http://www.contoso.com");
});
options.AddPolicy("AnotherPolicy",
builder =>
{
builder.WithOrigins("http://www.contoso.com")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
Add multiple CORS policies in Program.cs to enable Development and Production CORS Policies in place.