Не устанавливаются Cookie
Во время авторизации аккаунта с сервера (.net 6 asp.net core) приходит Set-Cookie. На фронтенде (angular 17.0.9) это отображается, Однако cookie не устанавливаются. Backend запускается на порту 5001. Angular на 4200. В чем может быть проблемма?

[HttpPost]
public async Task<string> Login([FromBody] UserLoginDTO user)
{
var result = await signInManager.PasswordSignInAsync(user.Login, user.Password, true, false);
var returnedData = new LoginUserDataDTO();
if (result.Succeeded)
{
returnedData.Login = user.Login;
returnedData.Error = false;
return JsonConvert.SerializeObject(returnedData);
}
else
{
returnedData.Error = true;
returnedData.ErrorMessage = "Wrong login or password";
return JsonConvert.SerializeObject(returnedData);
}
}
Program:
builder.Services.AddCors(o => o.AddPolicy("DevCorsPolicy", builder =>
{
builder
.WithOrigins("http://localhost:4200")
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
}));
// DB Services
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<AMContext>(options => options.UseSqlServer(connectionString), ServiceLifetime.Transient);
builder.Services.AddDbContext<AMIdentityContext>(options => options.UseSqlServer(connectionString), ServiceLifetime.Transient);
builder.Services.AddIdentity<DBUser, IdentityRole>(config =>
{
config.Password.RequireNonAlphanumeric = false;
config.Password.RequiredLength = 1;
config.Password.RequireUppercase = false;
config.Password.RequireDigit = false;
config.Password.RequireLowercase = false;
})
.AddEntityFrameworkStores<AMIdentityContext>()
.AddDefaultTokenProviders();
builder.Services.AddAuthorization();
var app = builder.Build();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseCors("DevCorsPolicy"); // TODO edit to before deploy
app.UseStaticFiles();
app.UseHangfireDashboard();
app.MapControllers();
RecurringJob.AddOrUpdate<HangFireTaskManager>("TaskParser", (method) => method.TaskParser(), "*/1 * * * * *");
RecurringJob.AddOrUpdate<HangFireTaskManager>("PostParser", (method) => method.PostParser(), "*/1 * * * * *");
RecurringJob.AddOrUpdate<HangFireTaskManager>("MonitorStatus", (method) => method.MonitorStatus(), "*/1 * * * * *");
RecurringJob.AddOrUpdate<HangFireTaskManager>("CommentParser", (method) => method.CommentParser(), "*/1 * * * * *");
RecurringJob.AddOrUpdate<HangFireTaskManager>("LikesParser", (method) => method.LikesParser(), "*/1 * * * * *");
// Init Roles
using (var scope = app.Services.CreateScope())
{
var services = scope.ServiceProvider;
try
{
var rolesManager = services.GetRequiredService<RoleManager<IdentityRole>>();
await RoleInitializer.InitializeAsync(rolesManager);
}
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occurred while seeding the database.");
}
}
app.Run();
