Setting up Charles to monitor outgoing Node app requests
- Add
global-tunnel-ng
module and add something like
// Enable the proxy for outgoing http requests made by this server (dev only)
if (process.env.APP_ENV === 'development' && process.env.http_proxy) {
console.warn('http_proxy env variable is set, all outgoing requests will be proxied');
globalTunnel.initialize();
}
- Make sure to define
export NODE_TLS_REJECT_UNAUTHORIZED=0
since Node seems to ignore the Charles root cert - Define
http_proxy
andhttps_proxy
in env like normal:
export HTTP_PROXY=http://127.0.0.1:8888
export HTTPS_PROXY=$HTTP_PROXY
export http_proxy=$HTTP_PROXY
export https_proxy=$HTTP_PROXY