Page
integrations/dotnet/project-resources → "Filter endpoints in environment variables"
Source: project-resources.mdx
Problem
The TypeScript tab of the "Filter endpoints in environment variables" section states:
"The TypeScript AppHost doesn't currently expose WithEndpointsInEnvironment. To exclude an endpoint from environment variable injection, define only the endpoints you need and omit the admin endpoint from the project resource."
But the TypeScript AppHost does expose it. There is a dedicated ATS-friendly overload marked [AspireExport] — src/Aspire.Hosting/Ats/CoreExports.cs:
[AspireExport]
public static IResourceBuilder<ProjectResource> WithEndpointsInEnvironment(
this IResourceBuilder<ProjectResource> resource,
string[] endpointNames)
The predicate overload WithEndpointsInEnvironment(Func<EndpointAnnotation, bool> filter) is [AspireExportIgnore] because Func<> isn't ATS-compatible, and its comment explicitly points to the array-based export as "the ATS-friendly implementation."
It appears in the generated TypeScript surface — src/Aspire.Hosting/api/Aspire.Hosting.ats.txt:
Aspire.Hosting/withEndpointsInEnvironment(endpointNames: string[]) -> Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource
and the repository's own polyglot TypeScript AppHost uses it — tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.mts:
await project.withEndpointsInEnvironment(["https"]);
Note on semantics
The exported TypeScript overload takes an allow-list of endpoint names to include (string[]), which is the inverse of the C# predicate example on the page (which excludes endpoints by returning false). So the correct TypeScript guidance to keep admin out of the environment is to list the endpoints you want to keep:
await builder.addProject("apiservice", "../Networking.ApiService/Networking.ApiService.csproj")
.withHttpsEndpoint()
.withHttpsEndpoint({ port: 19227, name: "admin" })
.withEndpointsInEnvironment(["https"]); // include only "https"; "admin" is excluded
Suggested fix
Replace the "doesn't currently expose WithEndpointsInEnvironment" note in the TypeScript tab with the withEndpointsInEnvironment(endpointNames) allow-list form and an example, noting the include-vs-exclude semantic difference from the C# predicate overload.
Provenance
aspire.dev release/13.5 (project-resources.mdx); aspire release/13.5 (CoreExports.cs, Aspire.Hosting.ats.txt, PolyglotAppHosts TypeScript AppHost). Confirmed working live against the 13.5 candidate CLI 13.5.0-pr.17553.
Page
integrations/dotnet/project-resources→ "Filter endpoints in environment variables"Source:
project-resources.mdxProblem
The TypeScript tab of the "Filter endpoints in environment variables" section states:
But the TypeScript AppHost does expose it. There is a dedicated ATS-friendly overload marked
[AspireExport]—src/Aspire.Hosting/Ats/CoreExports.cs:The predicate overload
WithEndpointsInEnvironment(Func<EndpointAnnotation, bool> filter)is[AspireExportIgnore]becauseFunc<>isn't ATS-compatible, and its comment explicitly points to the array-based export as "the ATS-friendly implementation."It appears in the generated TypeScript surface —
src/Aspire.Hosting/api/Aspire.Hosting.ats.txt:and the repository's own polyglot TypeScript AppHost uses it —
tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.mts:Note on semantics
The exported TypeScript overload takes an allow-list of endpoint names to include (
string[]), which is the inverse of the C# predicate example on the page (which excludes endpoints by returningfalse). So the correct TypeScript guidance to keepadminout of the environment is to list the endpoints you want to keep:Suggested fix
Replace the "doesn't currently expose
WithEndpointsInEnvironment" note in the TypeScript tab with thewithEndpointsInEnvironment(endpointNames)allow-list form and an example, noting the include-vs-exclude semantic difference from the C# predicate overload.Provenance
aspire.dev
release/13.5(project-resources.mdx); aspirerelease/13.5(CoreExports.cs,Aspire.Hosting.ats.txt,PolyglotAppHostsTypeScript AppHost). Confirmed working live against the 13.5 candidate CLI13.5.0-pr.17553.