Код: Выделить всё
public static void MapClientEndpoints (this IEndpointRouteBuilder routes)
{
var group = routes.MapGroup("/api/Client").WithTags(nameof(Client));
group.MapGet("/", async (HypnoContext db) =>
{
return await db.Client.ToListAsync();
})
.RequireAuthorization()
.WithName("GetAllClients")
.WithOpenApi();
}
Код: Выделить всё
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
.AddIdentityCookies();
builder.Services.AddIdentityCore(options =>
options.SignIn.RequireConfirmedAccount = true)
.AddRoles()
.AddEntityFrameworkStores()
.AddSignInManager()
.AddDefaultTokenProviders();
builder.Services
.AddScoped(sp => sp
.GetRequiredService()
.CreateClient("ServerAPI"))
.AddHttpClient("ServerAPI", (provider, client) =>
{
client.BaseAddress = new Uri(builder. Configuration["FrontendUrl"]);
});
Код: Выделить всё
ClientFactory = clientFactory;
httpClient = ClientFactory.CreateClient("ServerAPI");
Подробнее здесь: https://stackoverflow.com/questions/792 ... al-account