{"record":{"id":"dbfc2fc58f1b7721","repo":"microsoft/aspire","slug":"the-gateway-gateway-resource-name-must-define-an-http-or","errorCode":null,"errorMessage":"The gateway '{gateway.Resource.Name}' must define an HTTP or HTTPS endpoint.","messagePattern":"The gateway '(.+?)' must define an HTTP or HTTPS endpoint\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Blazor/BlazorGatewayExtensions.cs","lineNumber":333,"sourceCode":"\n        // Get or create the annotation on the gateway resource\n        var annotation = GetOrAddGatewayAppsAnnotation(gateway.Resource);\n\n        var gatewayOutputRoot = Path.Combine(\n            GetBlazorStorePath(gateway.ApplicationBuilder), \"gateways\", gateway.Resource.Name);\n\n        if (!annotation.IsInitialized)\n        {\n            annotation.IsInitialized = true;\n            MirrorGatewayStateToClients(gateway);\n\n            gateway.WithEnvironment(async context =>\n            {\n                var registeredApps = GetRegisteredApps(gateway.Resource);\n                var httpsGatewayEndpoint = GetEndpointIfDefined(gateway.Resource, \"https\");\n                var httpGatewayEndpoint = GetEndpointIfDefined(gateway.Resource, \"http\");\n                var gatewayEndpoint = httpsGatewayEndpoint ?? httpGatewayEndpoint\n                    ?? throw new InvalidOperationException($\"The gateway '{gateway.Resource.Name}' must define an HTTP or HTTPS endpoint.\");\n\n                // Resolve the HTTP OTLP endpoint for WASM client proxying.\n                // WASM clients use HTTP/protobuf (not gRPC), so we need the HTTP endpoint.\n                // First try to resolve from the dashboard resource model (handles randomized ports\n                // and isolated mode). Fall back to configuration for cases where the dashboard\n                // resource isn't in the model (e.g. external dashboard).\n                var httpOtlpEndpointUrl = ResolveHttpOtlpEndpointUrl(context, gateway.ApplicationBuilder.Configuration);\n\n                if (httpOtlpEndpointUrl is null && registeredApps.Any(a => a.ProxyBlazorTelemetry))\n                {\n                    context.Logger.LogWarning(\n                        \"OTLP telemetry proxying was requested but no dashboard HTTP endpoint could be resolved. \" +\n                        \"WASM client telemetry will not be forwarded.\");\n                }\n\n                if (context.ExecutionContext.IsPublishMode)\n                {\n                    ConfigurePublishEnvironment(context, registeredApps, gatewayEndpoint, httpGatewayEndpoint);","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Blazor/BlazorGatewayExtensions.cs#L315-L351","documentation":"WithBlazorApp's environment callback needs a gateway endpoint (https preferred, else http) to point WASM clients at the gateway. If the gateway resource defines neither an http nor https endpoint, the callback throws an InvalidOperationException when configuring environment variables.","triggerScenarios":"Calling gateway.WithBlazorApp(...) on a gateway resource created without WithEndpoint/WithHttpEndpoint/WithHttpsEndpoint, then starting the app so the environment callback executes.","commonSituations":"Manually building a gateway resource and forgetting endpoints; renaming/removing endpoint definitions during refactoring; conditional endpoint registration that never runs.","solutions":["Add an endpoint to the gateway: .WithHttpEndpoint() or .WithHttpsEndpoint().","Use AddBlazorGateway which configures endpoints for you.","Verify with gateway.Resource.EndpointCollection / annotations that http or https exists before calling WithBlazorApp.","Ensure endpoint names are exactly \"http\"/\"https\" since lookup is by scheme."],"exampleFix":"// before\nvar gateway = builder.AddBlazorGateway(\"gateway\", scriptPath);\n// after\nvar gateway = builder.AddBlazorGateway(\"gateway\", scriptPath).WithHttpEndpoint();","handlingStrategy":"validation","validationCode":"var hasEndpoint = gateway.Resource.Annotations.OfType<EndpointAnnotation>()\n    .Any(e => e.Scheme is \"http\" or \"https\");\nif (!hasEndpoint) throw new InvalidOperationException(\"Gateway needs an http or https endpoint before WithBlazorApp.\");","typeGuard":null,"tryCatchPattern":"try { gateway.WithBlazorApp(app); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"must define an HTTP or HTTPS endpoint\")) { logger.LogError(ex, \"Add WithHttpEndpoint/WithHttpsEndpoint to the gateway\"); throw; }","preventionTips":["Always call WithHttpEndpoint/WithHttpsEndpoint on custom gateways.","Prefer AddBlazorGateway, which wires endpoints for you.","Add an AppHost startup assertion that the gateway exposes an endpoint."],"tags":["blazor","gateway","endpoint","configuration","wasm"],"backgroundTag":"missing-required-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}