I am using the below code in ASP.NET Core
services.AddCors(policy => policy.AddPolicy(Constant.CorsPolicy, builder =>
{
var allowedDomain = configuration.GetValue<string>("AllowedDomains").Split(",");
services.AddCors(policy => policy.AddPolicy(Constant.CorsPolicy, builder =>
{
builder.WithOrigins(allowedDomain)
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyMethod()
.AllowAnyHeader();
}));
}));
to allow all subdomain and main domain, what this code does that it allow all subdomain, but it does not allow the main domain, I am reading values from configurations.
"AllowedDomains": "https://.test.dk, http://.test.dk, http://test.dk"
The following api is not allowed when its hit:
https://api.test.dk/api/v1/Product/Search