The api project on .net 8 already has the cors setup in Program.cs like this
builder.Services.AddCors(options =>
{
options.AddPolicy(name: "CorsPolicy",
policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
...
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCors("CorsPolicy");
app.UseAuthorization();
this works fine on endpoints like, /users, /users/5, /users/subpath/5?=param=3
but now I have the next endopint /jobs?param=5
and CORS return on preflght 401 Unauthorized
i tried adding
.SetIsOriginAllowed(_ => true)
like thiks
builder.AllowAnyMethod()
.SetIsOriginAllowed(_ => true)
.AllowAnyHeader()
.AllowCredentials();
but not works