Skip to content

Commit

Permalink
When using Aspire locally always use the same port, without proxying (#…
Browse files Browse the repository at this point in the history
…287)

Aspire by default randomizes ports, however this means that cookies from
a previous session most likely don't work, in which case the workbench
show the set of initial banners and asks to sign in, every time.

The PR changes this behavior on localhost, to always use port 4000
(assuming it's free), similarly to how the app runs without Aspire.
  • Loading branch information
dluc authored Dec 13, 2024
1 parent 68211b2 commit 1b2de09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion aspire-orchestrator/Aspire.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ private static IDistributedApplicationBuilder AddSemanticWorkbench(this IDistrib
// When running locally
if (!builder.ExecutionContext.IsPublishMode)
{
workbenchApp.WithHttpsEndpoint(env: "PORT");
if (!int.TryParse(builder.Configuration["Workbench:AppPort"], out var appPort)) { appPort = 4000; }
workbenchApp.WithHttpsEndpoint(port: appPort, env: "PORT", isProxied: false);
}

return builder;
Expand Down
10 changes: 8 additions & 2 deletions aspire-orchestrator/Aspire.AppHost/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
"Aspire.Hosting.Dcp": "Warning"
}
},
"Workbench": {
// Used only when running Aspire locally, ie not in the cloud
// Port 4000 is the default port used also when not using Aspire.
// Using the same port allows to keep cookies and other local settings.
"AppPort": 4000
},
"EntraID": {
"ClientId": "22cb77c3-ca98-4a26-b4db-ac4dcecba690",
"Authority": "https://login.microsoftonline.com/common"
"Authority": "https://login.microsoftonline.com/common",
"ClientId": "22cb77c3-ca98-4a26-b4db-ac4dcecba690"
}
}

0 comments on commit 1b2de09

Please sign in to comment.