dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.24k stars 316 forks source link

`localhost` should be replaced with appropriate hostname when present in an EndpointReferenceExpression. #4101

Closed mitchdenny closed 1 month ago

mitchdenny commented 1 month ago

Consider the following code:

https://github.com/mitchdenny/nocodb-aspire/blob/90ddebde4362508c7c4c8358b110d778baa80446/src/NocoDB/NocoDB.Hosting/NocoDBExtensions.cs#L21-L32

In this code I am constructing a custom connection string for NocoDB which points to a Postgres database (note I could just use the string interpolation handler thing, it amounts to the same thing).

The problem is that when I use the code like this:

https://github.com/mitchdenny/nocodb-aspire/blob/90ddebde4362508c7c4c8358b110d778baa80446/src/NocoDB/NocoDB.AppHost/Program.cs#L6-L10

... where I have one container referencing another container (NocoDB is referencing Postgres) ... I need the hostname to be host.docker.internal or the Podman alternative. But the transformation that we do for EndpointReference and ConnectionStringReference don't work. We need this transformation to work for EndpointReferenceExpression as well (the result from EndpointReference.Property(EndpointProperty.Host)).

Here is the code in question:

https://github.com/dotnet/aspire/blob/c6b9f8e195f5b1cd72951f447d35aae527b381b4/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs#L1299-L1303

davidfowl commented 1 month ago

Dupe of https://github.com/dotnet/aspire/issues/3735