MAUI-ba is jól bele lett rakva a Bearer token, ha van.

This commit is contained in:
2025-03-14 12:19:16 +01:00
parent 50b14e8122
commit a72c9b342e
9 changed files with 50 additions and 8 deletions
+5 -7
View File
@@ -11,6 +11,7 @@ using DevExpress.Maui;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
using CommunityToolkit.Maui.Core;
using WorkFlowCheck.MAUI.Handlers;
namespace WorkFlowCheck.MAUI
{
@@ -35,12 +36,9 @@ namespace WorkFlowCheck.MAUI
var configuration = new ConfigurationBuilder().SetBasePath(FileSystem.AppDataDirectory) // A konfigurációs fájl betöltése az alkalmazás adat könyvtárából
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
builder.Services.AddHttpClient<UserService>(client =>
{
var apiUrl = configuration["ApiBaseUrl"]; // API-cím betöltése a konfigurációból
client.BaseAddress = new Uri(apiUrl);
});
builder.Services.AddHttpClient();
builder.Services.AddDbContext<AppDbContext>();
builder.Services.AddSingleton<IConfiguration>(configuration);
@@ -64,9 +62,9 @@ namespace WorkFlowCheck.MAUI
#if DEBUG
builder.Logging.AddDebug();
#endif
// HttpClient regisztrálása az alap API-címmel
var app = builder.Build();
// Szolgáltató tárolása globálisan
ServiceProvider = app.Services;
return app;
}