microsoft/aspire · error · ArgumentException
Cannot find a http or https endpoint for this resource.
Error message
Cannot find a http or https endpoint for this resource.
What it means
This helper builds the canonical http(s) service URL reference for a resource and requires at least one http or https endpoint. When the resource has neither (the (false,false) switch case), it throws an ArgumentException naming the resource parameter.
Solutions
- Add an http or https endpoint to the resource, e.g. .WithHttpEndpoint(...) or .WithHttpsEndpoint(...), before generating the URL.
- Check hasHttpsEndpoint/hasHttpEndpoint detection by ensuring endpoint annotations exist on the exact resource passed in.
- If the resource legitimately has no endpoint, don't call this helper — construct the URL from configuration instead.
Example fix
// before
var app = builder.AddNpmApp("frontend", "./frontend");
var url = app.GetHttpUrl(); // throws
// after
var app = builder.AddNpmApp("frontend", "./frontend").WithHttpEndpoint(port: 3000);
var url = app.GetHttpUrl(); Defensive patterns
Strategy: validation
Validate before calling
var endpoints = resource.Resource.Annotations.OfType<EndpointAnnotation>().ToList();
if (!endpoints.Any(e => e.UriScheme is "http" or "https"))
throw new ArgumentException("Resource needs an http/https endpoint before generating its URL."); Try / catch
try { var url = ResourceUrlHelpers.GetUrl(resource); } catch (ArgumentException ex) when (ex.Message.Contains("http or https endpoint")) { /* configure endpoint first */ } Prevention
- Configure endpoints before URL generation in builder pipelines.
- Centralize endpoint setup in a helper so every resource gets one.
- Avoid calling URL helpers on endpoint-less worker resources.
When it happens
Trigger: Calling GetEndpoint-style URL helpers (e.g. the resource URL extension behind AddNextJsApp/JavaScript resources) on a resource with no http/https endpoint annotations.
Common situations: Calling the URL helper before endpoints are configured, on an endpoint-less worker resource, or after removing endpoints with a callback.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Resource ' ' does not have an HTTP or HTTPS endpoint…
- The apiPath must contain only URL-safe path characters…
- Toolbox ' ' did not resolve to an absolute HTTPS endpoint.
- A SearchIndexClient could not be configured. Ensure valid…
- apiPath is required when apiTarget is specified.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/5a0cf0a7eb5ff832.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs:3148
private static readonly string[] s_nextConfigFileNames = ["next.config.ts", "next.config.js", "next.config.mjs"];
/// <summary>
/// Builds a service discovery URL for the given resource, preferring HTTPS when available.
/// Mirrors the logic in <c>YarpCluster.BuildEndpointUri</c>.
/// </summary>
private static string BuildServiceDiscoveryUrl(IResourceWithServiceDiscovery resource)
{
var endpoints = resource.GetEndpoints();
var hasHttpsEndpoint = endpoints.Any(e => e.Exists && e.IsHttps);
var hasHttpEndpoint = endpoints.Any(e => e.Exists && e.IsHttp);
var scheme = (hasHttpsEndpoint, hasHttpEndpoint) switch
{
(true, true) => "https+http",
(true, false) => "https",
(false, true) => "http",
_ => throw new ArgumentException("Cannot find a http or https endpoint for this resource.", nameof(resource))
};
return $"{scheme}://{resource.Name}";
}
/// <summary>
/// Validates that the Next.js config file contains <c>output: "standalone"</c>.
/// </summary>
internal static void ValidateNextJsStandaloneOutput(string appDirectory)
{
foreach (var configFileName in s_nextConfigFileNames)
{
var configPath = Path.Combine(appDirectory, configFileName);
if (!File.Exists(configPath))
{
continue;
}
View on GitHub (pinned to 25830f84bd)