Skip to content

Commit 5b25f67

Browse files
authored
Include system environment variables when resolving ASPNETCORE_URLS (#107293)
1 parent 4ebb841 commit 5b25f67

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mono/wasm/host/BrowserHost.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ private async Task RunAsync(ILoggerFactory loggerFactory, CancellationToken toke
6868
debugging: _args.CommonConfig.Debugging);
6969
runArgsJson.Save(Path.Combine(_args.CommonConfig.AppPath, "runArgs.json"));
7070

71+
// Read system environment variables after runArgs.json is saved, so they won't be passed to browser.
72+
// But we need them to correctly read ASPNETCORE_URLS
73+
foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
74+
{
75+
if (de.Key is not null && de.Value is not null)
76+
envVars[(string)de.Key] = (string)de.Value;
77+
}
78+
7179
string[] urls = (envVars.TryGetValue("ASPNETCORE_URLS", out string? aspnetUrls) && aspnetUrls.Length > 0)
7280
? aspnetUrls.Split(';', StringSplitOptions.RemoveEmptyEntries)
7381
: new string[] { $"http://127.0.0.1:{_args.CommonConfig.HostProperties.WebServerPort}", "https://127.0.0.1:0" };

0 commit comments

Comments
 (0)