Inspect API calls made by a Heroku app
Published in
1 min readFeb 28, 2018
Imagine your Heroku app consumes some API like this:
# your-heroku-app.rb
Net::HTTP.get('example.com', '/index.json')
You can debug the traffic between your app and the API provider by putting a reverse proxy in front of it:
$ heroku plugins:install dockhero
$ heroku addons:create dockhero
$ heroku dh:docker run -d -p 80:8080 -p 8081:8081 johnmccabe/mitmweb \ -R https://example.com/
This launches mitmweb reverse proxy which forwards all incoming traffic to https://example.com/.
The proxy’s address is exposed via DOCKHERO_HOST
environment variable, so your app's code needs to be updated to make requests to the proxy:
# your-heroku-app.rb
Net::HTTP.get(ENV['DOCKHERO_HOST'], '/index.json')
Mitmweb proxy provides a nice dashboard where you can review and even replay the requests:
$ heroku dh:open 8081
Originally published at docs.dockhero.io.