Closed cfelstead closed 1 month ago
Hey @cfelstead 👋
Thanks for trying Dev Proxy, apologies for the trouble.
Command-line options for proxy settings suggests that you also need to specify the --proxy-server
option.
--proxy-bypass-list=(
| )[: ][;...] Tells Microsoft Edge to bypass any specified proxy for the specified semicolon-separated list of hosts. This flag must be used with --proxy-server.
Note
Trailing-domain matching doesn't require "." separators, "microsoft.com" will match "imicrosoft.com". For example, --proxy-server="proxy2:8080" --proxy-bypass-list=".microsoft.com;example.com;127.0.0.1:8080" will use the proxy server "proxy2" on port 8080 for all hosts except requests for .microsoft.com, example.com, and 127.0.0.1 on port 8080. In the previous example, imicrosoft.com requests will still be proxied. However, iexample.com requests will bypass the proxy because example.com was specified instead of .example.com.
Try adding the --proxy-server
option to the command line arguments.
msedge --proxy-bypass-list="<-loopback>" --proxy-server "127.0.0.1:8000"
Thanks @garrytrinder.
Sadly no change. I am also trying via powershell using the below with no luck.
curl -proxy http://127.0.0.1:8000 https://localhost:7271/Person
Can you tell me more about the local web service? I'll see if I can repro.
When I experienced the issue I wanted to rule out it being my API somehow. So I’ve replaced it with the default .net 8 weather forecast api.
This is a corporate machine so I’m not ruling out it being something to do with the setup there.
I did some investigation today and can repro, I'll do some more digging tomorrow.
@cfelstead I tested this scenario with a simple nodejs express API setup running on http://localhost:3000
, here are my findings.
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.json({ date: new Date() });
});
app.listen(3000, () => {
console.log(`Server is running on port 3000`);
});
{
"$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.1/rc.schema.json",
"plugins": [
{
"name": "GenericRandomErrorPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
"configSection": "genericRandomErrorPlugin"
}
],
"genericRandomErrorPlugin": {
"errorsFile": "errors.json"
},
"urlsToWatch": [
"http://localhost:3000*"
]
}
{
"$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.1/genericrandomerrorplugin.schema.json",
"responses": [
{
"statusCode": 500,
"body": "Internal Server Error",
"headers": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
]
}
var client = new HttpClient();
var response = await client.GetAsync("http://localhost:3000");
Console.WriteLine(response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Command | Passed Through |
---|---|
curl http://localhost:3000 |
❌ |
curl -x http://127.0.0.1:8000 http://localhost:3000 |
✅ |
dotnet run |
✅ * |
Invoke-WebRequest -Uri http://localhost:3000 |
✅* |
Invoke-WebRequest -Uri http://localhost:3000 -ProxyServer http://127.0.0.1:800 |
❌ |
curl
requires you to state the proxy you want to use in the command using -x
option.Screenshot of web server, proxy and tests
Thank you so much for you efforts @garrytrinder. I now have the application working as it should, however, only under certain conditions. Here are my notes. I am not ruling out some of these being specific to the work laptop in some way, however, hopefully they will help people in future.
On a windows machine, Powershell overrules the curl command as an alias for invoke-webrequest. As a result, I have needed to call the exe built into windows directly by referencing "curl.exe" and not just "curl".
HTTPS appears to be an issue. However, switching the API to load over HTTP works correctly.
So, in order to get work I did the following.
"urlsToWatch": [
"http://localhost:5256/*",
.......
]
Start devproxy in the windows terminal
Start the project (debug mode or not using a HTTP profile)
In a separate terminal running powershell, run the curl command as follows
curl.exe -x http://127.0.0.1:8000 http://localhost:5256/people
It is worth noting, I have not yet got it working without using curl.exe and specifying the proxy, for example, using a swagger UI. However, I am continuing to test and will report back with any news.
I can get Firefox to route through devproxy by setting the proxy server to 127.0.0.1:8000 and, in about:config
changing the network.proxy.allow_hijacking_localhost
setting to true.
I cannot get Chrome or Edge to behave with the launch command
msedge --proxy-bypass-list="<-loopback>" --proxy-server="127.0.0.1:8000"
Thanks for the updated info @cfelstead
I've been able to confirm that msedge --proxy-bypass-list="<-loopback>" --proxy-server="127.0.0.1:8000"
works for me on Windows 11 and Edge Beta (128.0.2739.5) this morning.
I noticed however that Dev Proxy did not intercept requests unless I used the --proxy-server
option, so we should update our docs to include that.
Interesting. I still can’t get it working.
I did get the vs debugger working correctly (so dotnet run) as long as the proxy was running prior to the debugger launching.
I think I’m in a place where it is working enough for me to proceed. It i can provide more assistance, please let me know. Otherwise, I’m happy to close this.
Thanks @cfelstead, I'll close this, but will work on updating the page to reference some of our findings in this issue. Thanks again for raising the issue, please let us know if there is anything we can help with.
Hi,
I have looked at the instructions here and believe I am doing everything right. But I am not seeing any requests intercepted by devproxy that are on localhost addresses (public addresses are logged and intercepted correctly).
Configuration file (I've only added one new url)
Starting visual studio and running my project in debug. Testing all is working correctly.
Starting devproxy via (actual path ommitted)
devproxy --config-file "C:\.....\devproxyrc.json"
Launching edge by doing Win + R and using the command
msedge --proxy-bypass-list="<-loopback>"
(have also tried replacing the<-loopback>
withlocalhost
andlocalhost:7271
)I'm sure I am missing something, but if I am, it is not clear what. Help appreciated.