Logging with an HTTP Proxy

Simple MITM debugging

Published January 22, 2021 #javascript, #logging, #proxy, #debugging

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

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

Then we run our script:

  node outdated.js

Then go visit http://localhost:8081 to see all of the requests that were made.

Simple and easy.

Read next

Next Post: Installing faasd
Previous Post: rails uuid primary key

See also

Simple CORS workaround for local development

I've been doing a lot of web development old school, just editing HTML and JavaScript by hand without a build environment. Running npx live-server is an easy one liner to spin up a server, that opens a browser for you and also updates changes on safe. Sometimes that's not enough. Often you want to pull in data from an API, and that requires HTTPS, and also you need to work around CORS limitations.

Read more

Beginning Emacs

Rediscovering emacs

Intro I've been dipping back ito the world of free software, and have been having a huge amount of fun getting back into emacs. I'm using it more of an operating system than I ever did before, as a way to navigate the world using a text interface. I'd never thought I'd be done with the terminal, but this is the first time that I've got something better and more powerful.

Read more