From a0297d40a8c1f3dca74770b61d42e61c110f376d Mon Sep 17 00:00:00 2001 From: OlgunR Date: Mon, 11 May 2026 15:13:28 +0200 Subject: [PATCH] Refactor API base URL config to use AppSettings object Replaced direct configuration access for the API base URL with retrieval from an AppSettings object. Updated HttpClient configuration to use appSettings.ApiBaseUrl, improving consistency and maintainability. Existing AppSettings DI registration is retained. --- DbFirst.BlazorWebApp/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DbFirst.BlazorWebApp/Program.cs b/DbFirst.BlazorWebApp/Program.cs index a477173..ef6ed42 100644 --- a/DbFirst.BlazorWebApp/Program.cs +++ b/DbFirst.BlazorWebApp/Program.cs @@ -13,12 +13,12 @@ builder.Services.AddDevExpressBlazor(options => options.BootstrapVersion = Boots builder.Services.AddScoped(); builder.Services.AddScoped(); -var apiBaseUrl = builder.Configuration["ApiBaseUrl"]; builder.Services.Configure(builder.Configuration); +var appSettings = builder.Configuration.Get() ?? new AppSettings(); void ConfigureClient(HttpClient client) { - if (!string.IsNullOrWhiteSpace(apiBaseUrl)) - client.BaseAddress = new Uri(apiBaseUrl); + if (!string.IsNullOrWhiteSpace(appSettings.ApiBaseUrl)) + client.BaseAddress = new Uri(appSettings.ApiBaseUrl); } builder.Services.AddHttpClient(ConfigureClient);