Skip to content

Commit 1b2de09

Browse files
authored
When using Aspire locally always use the same port, without proxying (microsoft#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.
1 parent 68211b2 commit 1b2de09

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

aspire-orchestrator/Aspire.AppHost/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ private static IDistributedApplicationBuilder AddSemanticWorkbench(this IDistrib
6868
// When running locally
6969
if (!builder.ExecutionContext.IsPublishMode)
7070
{
71-
workbenchApp.WithHttpsEndpoint(env: "PORT");
71+
if (!int.TryParse(builder.Configuration["Workbench:AppPort"], out var appPort)) { appPort = 4000; }
72+
workbenchApp.WithHttpsEndpoint(port: appPort, env: "PORT", isProxied: false);
7273
}
7374

7475
return builder;

aspire-orchestrator/Aspire.AppHost/appsettings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
"Aspire.Hosting.Dcp": "Warning"
77
}
88
},
9+
"Workbench": {
10+
// Used only when running Aspire locally, ie not in the cloud
11+
// Port 4000 is the default port used also when not using Aspire.
12+
// Using the same port allows to keep cookies and other local settings.
13+
"AppPort": 4000
14+
},
915
"EntraID": {
10-
"ClientId": "22cb77c3-ca98-4a26-b4db-ac4dcecba690",
11-
"Authority": "https://login.microsoftonline.com/common"
16+
"Authority": "https://login.microsoftonline.com/common",
17+
"ClientId": "22cb77c3-ca98-4a26-b4db-ac4dcecba690"
1218
}
1319
}

0 commit comments

Comments
 (0)