So here is my setup
- API = api.dev.mydomain.com
- SPA = dev.mydomain.com
the cors is not working here, is it because the SPA is the parent and the api is the subdomain?
CORS setup:
builder.Services.AddCors(opt =>
{
opt.AddPolicy(policy, builder =>
{
builder
.WithOrigins(new string[]
{
"http://*.mydomain.com",
"http://localhost:4200",
})
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials()
;
});
});
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme)
WebApplication app = builder.Build();
app.UseCors(policy);
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();