ngrokwebhookstutorial

Exposing Your Localhost with Ngrok (Very Useful for Testing Webhooks)

Rafael Thayto
Exposing Your Localhost with Ngrok (Very Useful for Testing Webhooks)

The "it works on my machine" problems are over!

# Problem

I needed to test some webhooks, but only knew one way which would be to deploy the app and only then be able to test the webhooks. This method works and is widely used by devs. But it has a problem... every test you need to deploy your application again and that takes quite some time.

Searching around I found Ngrok and with it we can expose our localhost in a very simple way.

# Installation

you can also follow the Official Documentation.

# Mac

Use Homebrew:

brew install ngrok/ngrok/ngrok

# Linux

Use apt

curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | \
  sudo gpg --dearmor -o /etc/apt/keyrings/ngrok.gpg && \
  echo "deb [signed-by=/etc/apt/keyrings/ngrok.gpg] https://ngrok-agent.s3.amazonaws.com buster main" | \
  sudo tee /etc/apt/sources.list.d/ngrok.list && \
  sudo apt update && sudo apt install ngrok

# Windows

Use Chocolatey

choco install ngrok

# Connect Your Agent to Your Ngrok Account

To do this, you need to log in or sign up on Ngrok and get your Authtoken.

Copy the token and add it to your terminal

ngrok config add-authtoken <TOKEN>

# Run Ngrok

Start Ngrok by running the command below (you can choose the port you prefer, but in the example I used port 8000):

ngrok http 8000

Thanks for reading this far! Hope this post helps you :)

Check out more at https://thayto.com/links

Cover Image: Photo by Stepan Kalinin on Unsplash

Exposing Your Localhost with Ngrok (Very Useful for Testing Webhooks) - Rafael Thayto