Step 1
Install nuGet package :
Microsoft.AspNetCore.Cors
Step 2
add
services.AddCors();
in startup.cs under ConfigureServices
Step 3
add
app.UseCors(x => x
.AllowAnyMethod()
.AllowAnyHeader()
.SetIsOriginAllowed(origin => true) // allow any origin
.AllowCredentials());
in startup.cs under Configure