Skip to content

Instantly share code, notes, and snippets.

@gpoole
Last active February 5, 2018 03:27
Show Gist options
  • Save gpoole/fc9a0f275ce6c55155bbbcd716088e0c to your computer and use it in GitHub Desktop.
Save gpoole/fc9a0f275ce6c55155bbbcd716088e0c to your computer and use it in GitHub Desktop.

Proxying Node apps with Charles

Setting up Charles to monitor outgoing Node app requests

// 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 and https_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment