diff --git a/src/Core/Extensions/Http.cs b/src/Core/Extensions/Http.cs index 439f1ff..4a17b71 100644 --- a/src/Core/Extensions/Http.cs +++ b/src/Core/Extensions/Http.cs @@ -20,9 +20,10 @@ internal static async Task ExecuteHttpProxyOperationAsync(this HttpContext conte try { - var httpClient = context.RequestServices - .GetService() - .CreateClient(options?.HttpClientName ?? Helpers.HttpProxyClientName); + var clientFactory = context.RequestServices.GetService() + ?? throw new InvalidOperationException("IHttpClientFactory not registered. You need to add builder.Services.AddHttpClient(); during startup"); + + var httpClient = clientFactory.CreateClient(options?.HttpClientName ?? Helpers.HttpProxyClientName); // If `true`, this proxy call has been intercepted. if(options?.Intercept != null && await options.Intercept(context).ConfigureAwait(false))