Webhook Testing

Learn how to test your webhooks.

Important

This feature is only included for the following templates:

Cloudflare Monorepo
Cli Monorepo
Vercel Monorepo

Testing on localhost

Services like Stripe provide webhooks to notify your app when certain events occur. However, when building your app on localhost, you will not be able to receive these webhooks because those same services will not be able to make requests to a localhost domain.

So in order to trigger your webhooks while developing locally, you will need to create a secure tunnel to localhost so that your local server can be made accessible via a public URL.

Setup

Important

This setup assumes that your domain is hosted on Cloudflare. If you are using a different DNS provider, you can consider using ngrok instead.

We recommend using Cloudflare Tunnel for tunneling to localhost. This is because it is free, the tunnels last forever, and you can lock your tunnel to a specific domain (allowing you to not have to keep updating your webhook's destination URL on Stripe or other services).

Creating a permanent tunnel

  1. Navigate to the Cloudflare Dashboard and click on the "Zero Trust" link on the left sidebar.
  2. Once you are on the Zero Trust dashboard, click on the "Networks" -> "Tunnels" link on the left sidebar.
  3. Click on the "Create a tunnel" button and select "Cloudflared".
  4. Enter a name for your tunnel and click on the "Save tunnel" button.
  5. Once your tunnel is created, you will be given multiple commands to run on your local machine.
    • If you don't already have cloudflared installed on your machine, run the command that is provided to install it.
    • Once you have cloudflared installed, run the command that is provided to install the tunnel.
      • This will configure your tunnel to automatically start when your machine boots up.
  6. Click on the "Public hostnames" tab at the top of the page.
    • Click the "Add a public hostname" button.
    • Under "Hostname", enter the public URL that you will use to test your webhooks.
      • We recommend using a subdomain of your domain on Cloudflare.
    • Under "Service", select "HTTP" for the type, and set the URL to 127.0.0.1:3000 (or whichever port you want to use for your local server).
  7. Provide Stripe with the public URL you specified in step 6 as the destination URL for your webhook.

Once you have completed the above steps, whenever you run http://localhost:3000, you will be able to access your local server via the public URL you specified in step 6 above. And Stripe will be able to send webhooks to your local server.