and another
All checks were successful
Build Docker Images / test (push) Successful in 1m15s
Build Docker Images / build-and-push (push) Successful in 1m39s

This commit is contained in:
2025-11-19 17:40:27 +01:00
parent 66a9b975a5
commit cfb0cdc2f7

View File

@@ -12,19 +12,26 @@ public static class ServiceCollectionExtensions
// Ensure BaseAddress ends with / for proper relative URL resolution
var baseUri = apiBaseUrl.EndsWith('/') ? apiBaseUrl : apiBaseUrl + "/";
Console.WriteLine($"🔧 Configuring HttpClient with BaseAddress: {baseUri}");
services.AddTransient<HttpLoggingHandler>();
services.AddHttpClient<AuthService>(client =>
// Configure named HttpClient with logging handler
services.AddHttpClient("DiunaBI", client =>
{
client.BaseAddress = new Uri(baseUri);
Console.WriteLine($"✅ HttpClient BaseAddress set to: {client.BaseAddress}");
})
.AddHttpMessageHandler<HttpLoggingHandler>();
services.AddHttpClient<LayerService>(client =>
// Register a scoped HttpClient factory that services will use
services.AddScoped<HttpClient>(sp =>
{
client.BaseAddress = new Uri(baseUri);
})
.AddHttpMessageHandler<HttpLoggingHandler>();
var factory = sp.GetRequiredService<IHttpClientFactory>();
var client = factory.CreateClient("DiunaBI");
Console.WriteLine($"🏭 HttpClient created from factory. BaseAddress: {client.BaseAddress}");
return client;
});
// Services
services.AddScoped<AuthService>();