{"record":{"id":"fc8989a5036c63c9","repo":"microsoft/aspire","slug":"the-host-host-resource-name-must-define-an-http-or-https","errorCode":null,"errorMessage":"The host '{host.Resource.Name}' must define an HTTP or HTTPS endpoint.","messagePattern":"The host '(.+?)' must define an HTTP or HTTPS endpoint\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Blazor/BlazorHostedExtensions.cs","lineNumber":139,"sourceCode":"                host.ApplicationBuilder.OnBeforeStart(async (beforeStartEvent, cancellationToken) =>\n                {\n                    var logger = beforeStartEvent.Services\n                        .GetRequiredService<ILoggerFactory>()\n                        .CreateLogger(typeof(BlazorHostedExtensions));\n                    annotation.DebuggerClientProjectPath = await ResolveBlazorWasmClientProjectPathAsync(\n                        projectMetadata.ProjectPath,\n                        logger,\n                        cancellationToken).ConfigureAwait(false);\n                });\n            }\n        }\n\n        host.WithEnvironment(context =>\n        {\n            var httpsHostEndpoint = GetEndpointIfDefined(host.Resource, \"https\");\n            var httpHostEndpoint = GetEndpointIfDefined(host.Resource, \"http\");\n            var hostEndpoint = httpsHostEndpoint ?? httpHostEndpoint\n                ?? throw new InvalidOperationException($\"The host '{host.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            var httpOtlpEndpointUrl = BlazorGatewayExtensions.ResolveHttpOtlpEndpointUrl(context, host.ApplicationBuilder.Configuration);\n\n            if (httpOtlpEndpointUrl is null && annotation.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            GatewayConfigurationBuilder.EmitHostedProxyConfiguration(\n                context.EnvironmentVariables,\n                hostEndpoint,\n                httpHostEndpoint,\n                $\"{host.Resource.Name} (client)\",\n                annotation.Services,","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Blazor/BlazorHostedExtensions.cs#L121-L157","documentation":"EnsureEnvironmentCallback in the hosted-Blazor path requires the host resource to expose an https or http endpoint so it can compute the URL handed to WASM clients. If neither scheme is defined, it throws an InvalidOperationException while configuring the host's environment.","triggerScenarios":"ProxyBlazorService/ProxyBlazorTelemetry wiring runs host.WithEnvironment(...) on a Blazor host resource lacking both http and https endpoints; callback executes at app start.","commonSituations":"Host project created without WithHttpEndpoint/WithHttpsEndpoint; endpoints added conditionally; switching a host from https-only templates to custom endpoint configuration that dropped both schemes.","solutions":["Add .WithHttpEndpoint() or .WithHttpsEndpoint() to the Blazor host resource.","Use the standard hosted Blazor extension that configures endpoints automatically.","Confirm endpoint names/schemes are exactly \"http\"/\"https\" as GetEndpointIfDefined expects.","Check EndpointCollection annotations on host.Resource before starting the app."],"exampleFix":"// before\nvar host = builder.AddProject<Projects.Host>(\"host\");\n// after\nvar host = builder.AddProject<Projects.Host>(\"host\").WithHttpEndpoint();","handlingStrategy":"validation","validationCode":"var hasEndpoint = host.Resource.Annotations.OfType<EndpointAnnotation>()\n    .Any(e => e.Scheme is \"http\" or \"https\");\nif (!hasEndpoint) throw new InvalidOperationException(\"Blazor host needs an http or https endpoint.\");","typeGuard":null,"tryCatchPattern":"try { ConfigureHost(host); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"must define an HTTP or HTTPS endpoint\")) { logger.LogError(ex, \"Add WithHttpEndpoint/WithHttpsEndpoint to the Blazor host\"); throw; }","preventionTips":["Add WithHttpEndpoint/WithHttpsEndpoint to every hosted Blazor host.","Use the standard hosted Blazor extensions rather than manual WithEnvironment wiring.","Keep endpoint schemes exactly \"http\"/\"https\"."],"tags":["blazor","host","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"}