microsoft/aspire · error · InvalidOperationException

Resource ' ' does not have an HTTP or HTTPS endpoint…

Error message

Resource '{parentResource.Name}' does not have an HTTP or HTTPS endpoint. Browser debugging requires an endpoint to navigate to.

What it means

WithBrowserDebugger() requires the JavaScript resource to expose an HTTP or HTTPS endpoint so the browser can be pointed at a running URL. The library scans the resource's endpoint annotations for an https endpoint (falling back to http); if neither exists it cannot construct a launch URL and throws this InvalidOperationException at model-build time.

Solutions

  1. Add an HTTP or HTTPS endpoint to the resource, e.g. .WithEndpoint(scheme: "http", targetPort: 3000) or .WithHttpEndpoint(port: 3000) before WithBrowserDebugger().
  2. Verify the endpoint is on the same resource you call WithBrowserDebugger() on (parentResource), not on a dependency.
  3. Check the endpoints list isn't filtered; the code picks https first, then http — either scheme satisfies it.

Example fix

// before
var app = builder.AddNpmApp("frontend", "./frontend")
    .WithBrowserDebugger();
// after
var app = builder.AddNpmApp("frontend", "./frontend")
    .WithHttpEndpoint(port: 3000)
    .WithBrowserDebugger();
Defensive patterns

Strategy: validation

Validate before calling

var hasEndpoint = app.Resource.Annotations.OfType<EndpointAnnotation>().Any(e => e.UriScheme is "http" or "https");
if (!hasEndpoint) throw new InvalidOperationException("Add an http/https endpoint before WithBrowserDebugger().");

Try / catch

try { app.WithBrowserDebugger(); } catch (InvalidOperationException ex) when (ex.Message.Contains("HTTP or HTTPS endpoint")) { /* add endpoint or disable browser debugging */ }

Prevention

When it happens

Trigger: Calling WithBrowserDebugger() on a JavaScript/Node resource that has no WithEndpoint/WithHttpEndpoint/WithHttpsEndpoint and no default endpoints (e.g. a plain AddNpmApp/AddViteApp without WithEndpoint, or a resource whose endpoints were removed).

Common situations: Developers add browser debugging to a worker/API-only Node app, forget to add an endpoint annotation, or reference a parent resource whose endpoints are defined on a child/reference target.

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


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/39181747815e9ff9. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs:2963

        builder.ApplicationBuilder.AddResource(debuggerResource)
            .WithParentRelationship(parentResource)
            .WaitFor(builder)
            .ExcludeFromManifest()
            .WithDebugSupport(
                mode =>
                {
                    // Resolve endpoint at run time so dynamically added endpoints are reflected
                    EndpointAnnotation? endpointAnnotation = null;
                    if (parentResource.TryGetAnnotationsOfType<EndpointAnnotation>(out var endpoints))
                    {
                        endpointAnnotation = endpoints.FirstOrDefault(e => e.UriScheme == "https")
                            ?? endpoints.FirstOrDefault(e => e.UriScheme == "http");
                    }

                    if (endpointAnnotation is null)
                    {
                        throw new InvalidOperationException(
                            $"Resource '{parentResource.Name}' does not have an HTTP or HTTPS endpoint. Browser debugging requires an endpoint to navigate to.");
                    }

                    var endpointReference = parentResource.GetEndpoint(endpointAnnotation.Name);

                    return new BrowserLaunchConfiguration
                    {
                        Mode = mode,
                        Url = endpointReference.Url,
                        WebRoot = parentResource.WorkingDirectory,
                        Browser = browser
                    };
                },
                BrowserCapability);

        return builder;
    }

View on GitHub (pinned to 25830f84bd)