I\'ve already enabled CORS on the project in C# .net Core
In startup.cs
I\'ve added lines
...
services.AddCors();
...
app.UseCors(builder =
It's little bit late, but I hope it could be helpful for someone.
If you want AllowCredentials()
and AllowAnyOrigin()
together just use SetIsOriginAllowed(Func<string,bool> predicate)
doc about IsOriginAllowed
services
.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
);
options.AddPolicy("signalr",
builder => builder
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()
.SetIsOriginAllowed(hostName => true));
});