Proxy nodejs requests through Proxy Server


If you want to proxy all Nodejs HTTP requests through a proxy server, just like JVM’s

-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888

Here is the quickest solution, without modifying the application source code

npm i global-agent
export GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:8888
node -r 'global-agent/bootstrap' app.js

This will enable you to proxy all requests through proxy server running at 127.0.0.1 on port 8888, which could be Charles or Burp