Skip to content

Commit a681e53

Browse files
authored
[wasm][debugger] Support NO_PROXY": "localhost" in launchSettings.json (#49395)
* support no_proxy configuration on launchSettings.json * fix compilation * Addressing @mkArtakMSFT comment. * Adding braces
1 parent c52c200 commit a681e53

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Components/WebAssembly/Server/src/DebugProxyLauncher.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ public static Task<string> EnsureLaunchedAndGetUrl(IServiceProvider serviceProvi
3838
}
3939
}
4040

41+
private static string GetIgnoreProxyForLocalAddress()
42+
{
43+
var noProxyEnvVar = Environment.GetEnvironmentVariable("NO_PROXY");
44+
if (noProxyEnvVar is not null)
45+
{
46+
if (noProxyEnvVar.Equals("localhost") || noProxyEnvVar.Equals("127.0.0.1"))
47+
{
48+
return "--IgnoreProxyForLocalAddress True";
49+
}
50+
Console.WriteLine($"Invalid value for NO_PROXY: {noProxyEnvVar} (Expected values: \"localhost\" or \"127.0.0.1\")");
51+
}
52+
return "";
53+
}
54+
4155
private static async Task<string> LaunchAndGetUrl(IServiceProvider serviceProvider, string devToolsHost, bool isFirefox)
4256
{
4357
var tcs = new TaskCompletionSource<string>();
@@ -46,11 +60,11 @@ private static async Task<string> LaunchAndGetUrl(IServiceProvider serviceProvid
4660
var executablePath = LocateDebugProxyExecutable(environment);
4761
var muxerPath = DotNetMuxer.MuxerPathOrDefault();
4862
var ownerPid = Environment.ProcessId;
49-
63+
var ignoreProxyForLocalAddress = GetIgnoreProxyForLocalAddress();
5064
var processStartInfo = new ProcessStartInfo
5165
{
5266
FileName = muxerPath,
53-
Arguments = $"exec \"{executablePath}\" --OwnerPid {ownerPid} --DevToolsUrl {devToolsHost} --IsFirefoxDebugging {isFirefox} --FirefoxProxyPort 6001",
67+
Arguments = $"exec \"{executablePath}\" --OwnerPid {ownerPid} --DevToolsUrl {devToolsHost} --IsFirefoxDebugging {isFirefox} --FirefoxProxyPort 6001 {ignoreProxyForLocalAddress}",
5468
UseShellExecute = false,
5569
RedirectStandardOutput = true,
5670
RedirectStandardError = true,

0 commit comments

Comments
 (0)