diff --git a/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs b/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs index 4c87a894a..cd6c9f647 100644 --- a/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs +++ b/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs @@ -32,7 +32,7 @@ public static class DependencyInjectionExtensions public static IServiceCollection AddElsaClient(this IServiceCollection services, Action configureOptions) { services.Configure(configureOptions); - services.AddSingleton(); + services.AddScoped(); services.AddActivityTypeService(); services.AddApi(CreateRefitSettings); @@ -71,6 +71,7 @@ public static class DependencyInjectionExtensions { var options = serviceProvider.GetRequiredService>().Value; httpClient.BaseAddress = options.BaseAddress; + options.ConfigureHttpClient?.Invoke(httpClient); } private static RefitSettings CreateRefitSettings(IServiceProvider serviceProvider) diff --git a/src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs b/src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs index 284ce4945..5dd5ccb64 100644 --- a/src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs +++ b/src/clients/Elsa.Api.Client/Options/ElsaClientOptions.cs @@ -14,4 +14,9 @@ public class ElsaClientOptions /// Gets or sets the API key to use when authenticating with the Elsa server. /// public string ApiKey { get; set; } = default!; + + /// + /// Gets or sets a delegate that can be used to configure the HTTP client. + /// + public Action? ConfigureHttpClient { get; set; } } \ No newline at end of file