diff --git a/src/Backend/DiunaBI.UI.Shared/Extensions/ServiceCollectionExtensions.cs b/src/Backend/DiunaBI.UI.Shared/Extensions/ServiceCollectionExtensions.cs index 92aba5c..7e59490 100644 --- a/src/Backend/DiunaBI.UI.Shared/Extensions/ServiceCollectionExtensions.cs +++ b/src/Backend/DiunaBI.UI.Shared/Extensions/ServiceCollectionExtensions.cs @@ -8,12 +8,14 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddSharedServices(this IServiceCollection services, string apiBaseUrl) { // HttpClient for API calls - services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(apiBaseUrl) }); - + // Ensure BaseAddress ends with / for proper relative URL resolution + var baseUri = apiBaseUrl.EndsWith('/') ? apiBaseUrl : apiBaseUrl + "/"; + services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseUri) }); + // Services services.AddScoped(); services.AddScoped(); - + return services; } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.UI.Web/Program.cs b/src/Backend/DiunaBI.UI.Web/Program.cs index bc76d66..7766bec 100644 --- a/src/Backend/DiunaBI.UI.Web/Program.cs +++ b/src/Backend/DiunaBI.UI.Web/Program.cs @@ -10,12 +10,10 @@ builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddMudServices(); -var apiBaseUrl = builder.Configuration["ApiSettings:BaseUrl"] +var apiBaseUrl = builder.Configuration["ApiSettings:BaseUrl"] ?? throw new InvalidOperationException("ApiSettings:BaseUrl is not configured"); builder.Services.AddSharedServices(apiBaseUrl); -builder.Services.AddScoped(); - var app = builder.Build(); if (!app.Environment.IsDevelopment())