Skip to content

Commit ba02892

Browse files
authored
Fix exception when app host has no ASPNETCORE_URLS (#1970)
If an app host project's launch profile doesn't specify a `launchUrl` or `applicationUrl` then the running app host won't have a `ASPNETCORE_URLS` environment variable. We want to pass this variable's value to the dashboard process, and currently if it's missing we throw. The dashboard executable has a fallback value when the `ASPNETCORE_URLS` variable is not present (of `http://localhost:18888`), so it's perfectly happy to run without this variable. This change causes the app host to fall back to that same default value for the dashboard's `ASPNETCORE_URLS` variable. While we could pass no value at all, and have the dashboard choose the default, it's more helpful to the user if we log the dashboard URL. This allows the user to find the dashboard, as the IDE will not be launching it automatically when in this state.
1 parent 1175a33 commit ba02892

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/Aspire.Hosting/Dcp/ApplicationExecutor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,11 @@ private async Task StartDashboardAsDcpExecutableAsync(CancellationToken cancella
199199
throw new DistributedApplicationException("Error getting the resource service URL.", ex);
200200
}
201201

202+
// Matches DashboardWebApplication.DashboardUrlDefaultValue
203+
const string defaultDashboardUrl = "http://localhost:18888";
204+
202205
var otlpEndpointUrl = environmentVariables.GetString("DOTNET_DASHBOARD_OTLP_ENDPOINT_URL");
203-
var dashboardUrls = environmentVariables.GetString("ASPNETCORE_URLS") ?? throw new DistributedApplicationException("ASPNETCORE_URLS environment variable not set.");
206+
var dashboardUrls = environmentVariables.GetString("ASPNETCORE_URLS") ?? defaultDashboardUrl;
204207
var aspnetcoreEnvironment = environmentVariables.GetString("ASPNETCORE_ENVIRONMENT");
205208

206209
dashboardExecutableSpec.Env =

0 commit comments

Comments
 (0)