Mobilról működik a hívás https-en :)
This commit is contained in:
@@ -11,19 +11,34 @@ namespace WorkFlowCheck.MAUI
|
||||
public static MauiApp CreateMauiApp()
|
||||
{
|
||||
var builder = MauiApp.CreateBuilder();
|
||||
|
||||
|
||||
// appsettings.json beállítása
|
||||
|
||||
string jsonFilePath = Path.Combine(FileSystem.AppDataDirectory, "appsettings.json");
|
||||
|
||||
// Másold a fájlt a Raw erőforrásokból az AppDataDirectory-ba, ha még nincs ott
|
||||
if (!File.Exists(jsonFilePath))
|
||||
{
|
||||
using var stream = FileSystem.OpenAppPackageFileAsync("appsettings.json").Result;
|
||||
using var reader = new StreamReader(stream);
|
||||
File.WriteAllText(jsonFilePath, reader.ReadToEnd());
|
||||
}
|
||||
|
||||
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.AddSingleton<IConfiguration>(configuration);
|
||||
|
||||
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.AddSingleton<IConfiguration>(configuration);
|
||||
builder.Services.AddSingleton<IUserService, UserService>();
|
||||
|
||||
|
||||
builder
|
||||
.UseMauiApp<App>()
|
||||
.ConfigureFonts(fonts =>
|
||||
@@ -33,10 +48,10 @@ namespace WorkFlowCheck.MAUI
|
||||
});
|
||||
|
||||
#if DEBUG
|
||||
builder.Logging.AddDebug();
|
||||
builder.Logging.AddDebug();
|
||||
#endif
|
||||
// HttpClient regisztrálása az alap API-címmel
|
||||
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user