Skip to content

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

Open

Description

@Pattrigue

Is there an existing issue for this?

  • 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.

Activity

  1. added
    area-app-model
    on Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-app-model

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions