using Microsoft.Extensions.DependencyInjection; using DiunaBI.UI.Shared.Services; namespace DiunaBI.UI.Shared.Extensions; public static class ServiceCollectionExtensions { public static IServiceCollection AddSharedServices(this IServiceCollection services, string apiBaseUrl) { // HttpClient for API calls // 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; } }