You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Followed instruction - DevProxy not intercepting localhost addresses #837
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).
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> with localhost and localhost:7271)
I'm sure I am missing something, but if I am, it is not clear what.
Help appreciated.
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.
@cfelstead I tested this scenario with a simple nodejs express API setup running on http://localhost:3000, here are my findings.
index.js
constexpress=require("express");constapp=express();app.get("/",(req,res)=>{res.json({date: newDate()});});app.listen(3000,()=>{console.log(`Server is running on port 3000`);});
After starting Dev Proxy, you must create a new session for Proxy to be picked up, or toggle Use Proxy Server checkbox in Internet Options -> Connections -> LAN Settings... for existing sessions
curl requires you to state the proxy you want to use in the command using -x option.
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.
Inside devproxyrc.json make sure the urlsToWatch contains the API url as HTTP.
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
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.
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.
Activity
garrytrinder commentedon Jul 26, 2024
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-serveroption.Try adding the
--proxy-serveroption to the command line arguments.cfelstead commentedon Jul 26, 2024
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/Persongarrytrinder commentedon Jul 26, 2024
Can you tell me more about the local web service? I'll see if I can repro.
cfelstead commentedon Jul 26, 2024
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.
garrytrinder commentedon Jul 29, 2024
I did some investigation today and can repro, I'll do some more digging tomorrow.
garrytrinder commentedon Jul 31, 2024
@cfelstead I tested this scenario with a simple nodejs express API setup running on
http://localhost:3000, here are my findings.index.js
devproxyrc.json
{ "$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*" ] }errors.json
{ "$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" } ] } ] }Program.cs
Tests
curl http://localhost:3000curl -x http://127.0.0.1:8000 http://localhost:3000dotnet runInvoke-WebRequest -Uri http://localhost:3000Invoke-WebRequest -Uri http://localhost:3000 -ProxyServer http://127.0.0.1:800curlrequires you to state the proxy you want to use in the command using-xoption.garrytrinder commentedon Jul 31, 2024
Screenshot of web server, proxy and tests
cfelstead commentedon Jul 31, 2024
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.
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/peopleIt 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.
cfelstead commentedon Jul 31, 2024
I can get Firefox to route through devproxy by setting the proxy server to 127.0.0.1:8000 and, in
about:configchanging thenetwork.proxy.allow_hijacking_localhostsetting 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"garrytrinder commentedon Aug 5, 2024
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-serveroption, so we should update our docs to include that.cfelstead commentedon Aug 5, 2024
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.
cfelstead commentedon Aug 5, 2024
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.
garrytrinder commentedon Aug 5, 2024
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.
garrytrinder commentedon Aug 5, 2024
https://github.com/MicrosoftDocs/microsoft-cloud-pr/pull/332