microsoft / microsoft/aspire

CreateHttpClient when explicitly requesting the "http" endpoint give HTTP scheme with HTTPS port (from testing project)

Open
#15,096 4 comments 0 reactions 0 assignees View on GitHub
area-app-model
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

Using `app.CreateHttpClient(resourceName, "http")` gives the wrong URL
I used it from an **Aspire Testing project**.

I use Yarp in the AppHost:
```
var gateway = builder.AddYarp("gateway")
.WithHostPort(8999)
.WithConfiguration(yarp => ... );
```
HostPort is explicitly set to 8999 and the "http" endpoint is correctly configured and reachable from the dashboard.

Image

As a result I get "http://localhost58457"; HTTP scheme with wrong port.

In the `DistributedApplicationHostingTestingExtensions`, at some point, the allocated endpoint is not the correct one and everything is mixed up down the line where the scheme and port don't match.

### Expected Behavior

Having the HTTP port with the correct scheme as requested.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version info

_No response_

### Anything else?

.NET 10
Aspire.AppHost.Sdk/13.1.2
Aspire.Hosting.Testing 13.1.2

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.