You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using named clients to Authorize my client access, and here I have multiple APIs using the same Named client.
Now I am creating multiple Refit Clients for multiple Interfaces (multiple different API URLs) and all use the same Named client to authenticate.
When I Inject the API Client Interfaces into my services/controller, from all Interfaces the BaseAdress is the last baseAddress from my Registered Refit Clients.
Step to reproduce
Here you can see my setup:
services.AddHttpClient("GitHubClient", client =>
{
client.BaseAddress = new Uri("https://api.github.com/");
client.DefaultRequestHeaders.Add("Accept", "application/json");
// Weitere Konfigurationen hier ...
});
services
.AddRefitClient(typeof(IArticlesApi), null, $"GitHubClient")
.ConfigureHttpClient(c => c.BaseAddress = new Uri("https://myArticlesApi.com"));
services
.AddRefitClient(typeof(IContentApi), null, $"GitHubClient")
.ConfigureHttpClient(c => c.BaseAddress = new Uri("https://myContentApi.com"));
when I now inject the "IContentApi" and the "IArticlesApi" into an Controller or Service/Provider
the Client.BaseAdress on both injected Interfaces is "https://myContentApi.com" => the last registered c.BaseAddress.
That seems to be wrong I would say, because, when I Use multiple different named clients, then each BaseAddress is like expected.
Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
Windows 10
Version
No response
Device
No response
Refit Version
7.0.0
Additional information ℹ️
No response
The text was updated successfully, but these errors were encountered:
This is expected behavior. You're just reconfiguring the same IHttpClientFactory, and the actual clients aren't instantiated until injection time, and the factory produces different instances for each injection site, they are not all the same reference to the same client.
Describe the bug 🐞
I am using named clients to Authorize my client access, and here I have multiple APIs using the same Named client.
Now I am creating multiple Refit Clients for multiple Interfaces (multiple different API URLs) and all use the same Named client to authenticate.
When I Inject the API Client Interfaces into my services/controller, from all Interfaces the BaseAdress is the last baseAddress from my Registered Refit Clients.
Step to reproduce
Here you can see my setup:
Reproduction repository
https://github.com/reactiveui/refit
Expected behavior
when I now inject the "IContentApi" and the "IArticlesApi" into an Controller or Service/Provider
the Client.BaseAdress on both injected Interfaces is "https://myContentApi.com" => the last registered c.BaseAddress.
That seems to be wrong I would say, because, when I Use multiple different named clients, then each BaseAddress is like expected.
Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
Windows 10
Version
No response
Device
No response
Refit Version
7.0.0
Additional information ℹ️
No response
The text was updated successfully, but these errors were encountered: