-
Notifications
You must be signed in to change notification settings - Fork 0
Ngrok Guide (For Webhook Testing)
This guide covers how to expose our local api-gateway to the internet using ngrok, so Resend's webhook can send requests to our backend during local testing.
We are using Resend's webhook to keep track of all our outgoing emails. To use the webhook we need a publicly available URL to our api-gateway, which is a problem if you are running it locally. Therefore we use Ngrok to create a temporary public tunnel to our local server.
Local install:
pnpm add ngrok
Global install:
pnpm add -g ngrok
Note
I recommend using the local install but global should work.
The auth token will be shared privately
pnpm ngrok config add-authtoken <AUTH_TOKEN>
pnpm ngrok http 3001
After a second or two a public ngrok URL will be provided in console. Ex: https://example.ngrok-free.dev
In the Resend dashboard, navigate to the "Webhooks" page. There you must edit the existing webhook to use the URL:
<NEWLY_GENERATED_URL>/api/webhook/create
Once your finished, close the public tunnel by typing CTRL + C in the terminal ngrok is running.
- The ngrok URL changes every time you restart the tunnel, meaning you need to update the URL in Resend each time.
- Use ngrok sparingly since opening a public tunnel is not very safe.