I\'m not sure what I\'m missing, but can\'t seem to get my CORS Policy working with .NET Core 3.1 and Angular 8 client-side.
Startup.cs:
first app.UseRouting(); then app.UseCors("foo");
Change your Configure method like the following :
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting(); // first
// Use the CORS policy
app.UseCors("foo"); // second
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
It worked for me !