microsoft / microsoft/aspire

Expose network-context endpoint resolution (container-reachable URL) in the polyglot/TypeScript AppHost

Open
#18,787 0 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

### Is your feature request related to a problem? Please describe the problem.

In C#, an `EndpointReference` resolves per the consumer's network context (host → `localhost`, container → `host.docker.internal`), and you can force a context via `new EndpointReference(owner, endpoint, KnownNetworkIdentifiers.DefaultAspireContainerNetwork)`. The generated TypeScript binding exposes `EndpointReference` with only `.property(EndpointProperty)` / `.url` / `.host`, which resolve in the *consumer's* context — there's no way to construct a context-scoped reference or otherwise request the container-reachable form.

So when a host-process resource needs the container-reachable form of its **own** endpoint in its own env — e.g. a callback base URL that a container calls back into and validates against an allowlist (both sides must be the identical literal) — the TypeScript AppHost can't express it. We hardcode `http://host.docker.internal:${port}` on both the host app's env and the container's allowlist, plus `--add-host=host.docker.internal:host-gateway` for Linux.

The per-context behavior is verified by `tests/Aspire.Hosting.Tests/EndpointReferenceTests.cs` (`[Url, Container→Host]` → `host.docker.internal` vs `[Url, Host→Host]` → `localhost`).

### Describe the solution you'd like

Project a network-context selector to the polyglot surface — e.g. `endpoint.inNetwork("container" | "host")`, or expose the `contextNetworkId` constructor parameter / `KnownNetworkIdentifiers` — so guest AppHosts can obtain a container-reachable endpoint URL without hardcoding `host.docker.internal`.

### Additional context

Aspire CLI 13.4.6, TypeScript AppHost, container tunnel default-on (13.3+). Adjacent: #16641, #11401. Sibling polyglot-surface gap: #18786. Would likely ride the polyglot projection work in #16110.

Contributor guide

Open the contributing guide

Research direction

Start with tests/Aspire.Hosting.Tests/EndpointReferenceTests.cs to understand the existing host and container URL behavior, then inspect the polyglot projection work referenced by #16110. Done means the TypeScript AppHost can request a container-reachable endpoint URL for a host-process resource without hardcoding host.docker.internal.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker, typescript
Domain
developer-experience, devtools, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.