Webhook debugging with ngrok
There are several tools to reroute external webhook urls to local dev. Ngrok is one of the easier options and works with multiple host header files locally with some commands. There are alternatives like localtunnel
- Sign up for a free ngrok account
- Download the mechanism you wish to run ngrok ( single binary, container, zip file ). This example uses single binary on Windows
- Create a local folder to hold the binary and config files e.g.
c:\ngrok
- Run ngrok binary from the command line and add your
authtoken
(you only have to do this once). Commandngrok config add-authtoken <token>
Now you are setup to re-route dynamic public urls to your local machine. Further steps are ones I have created to debug and run ngrok to expose your local fast api to test webhooks publicly
- Create a
bat
file in the same folder as the ngrok binary. I have named itlocalapi.bat
- Add the following lines to open the ngrok log and setup the local dev fast api to receive public internet traffic
explorer http://127.0.0.1:4040
ngrok http --host-header=rewrite https://mylocalsite.something.com
- Now run the bat file and it will automatically start ngrok and open the request/response console, which you can make modifications on etc. It will look something like this