dotnet / dotnet/yarp

Service discovery on `MapForwarder` disabled when `httpClient` is assigned

Open
#2,838 8 comments 0 reactions 0 assignees View on GitHub
help wanted Type: Documentation
Dominant language
C#
Stars
9.6k
Forks
933
Avg merge
12d 18h
Merged PRs (30d)
2

Description

### Describe the bug
A clear and concise description of what the bug is.

### To Reproduce
1. Make Aspire project and create Yarp project with reference to `api` service.
2. Setup forwarder with following code.
```C#
var transformer = app.ServiceProvider.GetRequiredService().Create(transformBuilderContext
=> transformBuilderContext
.AddPathRemovePrefix("/Api"));
#if ASSIGN_HTTP_CLIENT
var httpClient = new HttpMessageInvoker(new SocketsHttpHandler
{
UseProxy = false,
AllowAutoRedirect = true,
ConnectTimeout = TimeSpan.FromSeconds(30),
});
app.MapForwarder("/Api/{**apiPath}", "https://api", ForwarderRequestConfig.Empty, transformer, httpClient);

#else
app.MapForwarder("/Api/{**apiPath}", "https://api", ForwarderRequestConfig.Empty, transformer);
#endif
```
3. Access to forwarder's path and it works correctly.
4. define `ASSIGN_HTTP_CLIENT`.
5. Access to forwarder's path.
6. It respond with error codes, and logs say "No such host".
### Further technical details

- Include the version of the packages you are using
- Yarp.Reverse Proxy 2.3.0
- The platform (Linux/macOS/Windows)
- Windows 11 Pro 10.0.26100 Build 26100

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.