I miss having Chrome dev tools when writing node applications, since I often want to see what exactly the network traffic. Here's a way to easily setup a man in the middle proxy to look at all the traffic your application is generating.
Run the docker instance
First we first up the proxy with the web interface:
docker run --rm -it -p 8080:8080 -p 8081:8081 mitmproxy/mitmproxy mitmweb --web-host 0.0.0.0
Node ENV Variables
Then we set the proxy environment variable, and for node specifically, tell it to not worry about self-signed certificates:
export HTTP_PROXY=http://localhost:8080 export NODE_TLS_REJECT_UNAUTHORIZED='0'
Then we run our script:
Then go visit http://localhost:8081 to see all of the requests that were made.
Simple and easy.