.net core web api return cors error instead of 401
public void Configure(
IApplicationBuilder app,
IWebHostEnvironment env,
ApplicationDbContext dbContext,
UserManager<ApplicationUser> userManager,
RoleManager<UserRole> roleManager,
AppConfigs appConfigs
)
{
if (env.IsDevelopment())
{
app.UseExceptionHandler("/error-local-development");
}
else
{
app.UseExceptionHandler("/error");
}
app.UseRouting();
app.UseCors(MyAllowSpecificOrigins);
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseStaticFiles();
// ===== Create tables ======
DataInitializer.SeedData(dbContext, userManager, roleManager, appConfigs);
}