0👍
For testing at local, you should allow any domain access resource.
Replace this code with the one below
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowOrigin", policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.WithOrigins("http://localhost:5173");
});
});
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowOrigin", policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.WithOrigins("*");
});
});
Source:stackexchange.com