The origin is white-listed (http://localhost:4200/) in Startup.cs, yet the request is rejected due to Cors.
This is true for an a GET request on my API and when I try to establish a connection via SignalR. I'm able to get around Cors blocking the API request via AllowAllOrigins, but thats not a viable solution with SignalR, which requires .AllowCredentials.
The rejection shows I've white-listed the correct domain. It just seems like it isn't being honored.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
options.AddPolicy(MyAllowSpecificOrigins,
builder =>
{
builder
.WithMethods("GET","POST")
.AllowAnyHeader()
.AllowCredentials()
.WithOrigins("http://localhost:4200/");
}));
services.AddRazorPages();
services.AddControllers();
services.AddSignalR();
services.AddDbContext<WebApplication2Context>(options =>
options.UseSqlServer(Configuration.GetConnectionString("WebApplication2Context")));
}
I know the policy is being applied. When I change withOrigins to allOrigins it fails on startup.