Skip to content
inspect + replay

Webhooks, on localhost.

Your handler runs on localhost:3000. The provider needs an address it can resolve from the public internet, over HTTPS, and localhost on your machine is not one. A tunnel closes that gap: zgrok gives the port a public hostname with a real certificate, and forwards what arrives there to the port you named.

~/app · Stripe calling your handler
$ zgrok http 3000
✓ Online · hooks--acme-shop.zgrok.io → localhost:3000
POST/webhooks/stripe40012 ms
POST/webhooks/stripe200replayed
POST/webhooks/github20041 ms
POST/webhooks/stripe20035 ms
On this page

The routes that look shorter

Deploying to a staging environment

Deploying to a staging environment to read one payload works, and it costs you a build and a deploy per iteration. That is bearable once. It is not bearable at the rate you actually need when the payload nests one level deeper than you assumed.

Forwarding a port on your router

Forwarding a port on your router reaches your machine, but it wants a public address that does not move, a router you administer, and a certificate a provider will accept. It also exposes a development server that was written on the assumption that only you could reach it.

A hosted request bin

A hosted request bin gives you the payload to read, which is genuinely useful, and it stops exactly where your problem starts: your handler never runs, so the thing you are debugging is never exercised.

One command

  1. Run the command

    $ zgrok http 3000
  2. Register the URL

    The banner prints a public URL. Register it with the provider, path included, in whatever field their dashboard calls the endpoint. Which address you are handed is worth reading before you paste it, and the section on deciding the address covers it:
    text
    https://a7f9x2--acme-shop.zgrok.io/api/webhooks/stripe
  3. Trigger the event

    Trigger the event, and the request arrives at 127.0.0.1:3000 with the path you registered. The CLI dials 127.0.0.1 first and then ::1, so an app listening on either address is reached.

What the tunnel does to the request

Nothing is removed or rewritten.

This is the part worth being precise about, because a webhook is signed and a signature is computed over bytes.

On an HTTP tunnel the request head and body are relayed as they arrive. Every header the provider sent arrives spelled the way they sent it, in the order they sent it, with the body byte for byte behind it. Stripe-Signature and X-Hub-Signature-256 are not special cases here: there is no rewriting step on this path for them to survive. Our edge adds the usual X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host on the way in, the way any reverse proxy does, and touches nothing the provider sent.

The zgrok inspector: a list of six requests on the left, and on the right a POST to /webhooks/payments with its request headers, including a Stripe-Signature, and its JSON body, beside a Replay button.
A made-up delivery in the inspector: the signature header and the body, as they reached the local app.

Two consequences are worth knowing in advance rather than at three in the morning.

Host

The tunnel hostname

Because nothing in the head is rewritten, the Host your app sees is the tunnel hostname, not localhost: a framework that validates the request host against an allowlist will reject the delivery until you add that hostname.
HTTP

The hop to your app

The hop from the tunnel to your app is plain HTTP, so a framework that redirects HTTP to HTTPS will bounce the delivery unless it is told to trust X-Forwarded-Proto.

The response side is not quite as untouched, and none of it affects a webhook. zgrok stamps X-Robots-Tag: noindex, nofollow on responses it proxies, unless your backend already stated a robots policy, so a tunnel address asks search engines not to index it as a page on our domain. It also replaces whatever your backend said about connection reuse with Connection: close, because zgrok serves one request per TCP connection.

Decide the address before you paste it

A webhook endpoint is a URL you type into someone else's dashboard, which makes it the one place a changing address genuinely hurts. So it is worth knowing which one you are getting.

Free

An assigned address

On Free, an assigned address belongs to that run. It is rewritten on the next zgrok http 3000, which hands you a different name, and the endpoint you registered stops resolving to you. That is workable while you are still wiring things up, at the cost of re-registering, and it is the reason the section below exists.
Pro

A tunnel name you choose

On Pro, a tunnel name you choose inside your project is yours and comes back every session:
$ zgrok http 3000 --subdomain myapp

In a project called acme-shop, the endpoint stays https://myapp--acme-shop.zgrok.io/api/webhooks/stripe across restarts, so you register it once. A reconnect after a dropped connection keeps the address either way: the CLI pins the name it was given for the life of the process, so a network blip does not move your endpoint mid-session. It says so in the terminal on the one occasion it cannot, which is a tunnel deleted from the dashboard while the CLI was still holding its name.

Trigger once, then stop asking

Getting the delivery to arrive is the fast part. The loop after it is what takes the afternoon: fix a line, and now you need that same event again, so you go back to the provider and click resend, and again, and again.

Unless you turn it off, every tunnel runs a request inspector on your own machine and prints its address in the same banner:

Inspect: http://127.0.0.1:4040

Open a delivery, read its headers and body, and press Replay. zgrok sends the captured bytes straight to your local port rather than back out through the tunnel, so the provider never learns you re-ran anything and nothing fires again on their side. Your own handler runs again in full, side effects included, which is the point and worth remembering before you replay a payment event forty times.

The signature headers are the ones the provider computed, so verification is exercised for real rather than against a signature you made up in a saved curl command. The inspector holds the last 50 requests in memory for the life of the tunnel, and captures bodies up to 128 KB in each direction. A delivery whose body ran past that limit is captured but refused for replay, and says so, rather than being replayed as a body that contradicts its own Content-Length. It binds to loopback only, which matters here: those captured bodies hold whatever the provider sent you. Loopback does not keep web pages out by itself, so the inspector checks who is asking too.

You only need one delivery is the longer argument, including what replay will not do.

POST /webhooks/stripe · Stripe-Signature kept400
you fix the handler, then press Replay
POST /webhooks/stripe · replayed200

Who else can reach the URL

An assigned address is six random characters, which keeps the URL out of the way without protecting it. zgrok does not publish it, and because tunnel hostnames are served under a wildcard certificate, yours does not show up in a certificate transparency log the way a per-host certificate would. That is obscurity, not a control: a six-character name is small enough to enumerate, and anyone holding the URL reaches your handler for as long as the tunnel is up. For most webhook work that is fine, because the tunnel is up while you are sitting in front of it. When it is not fine, Pro tunnels can restrict which addresses are allowed through:

$ zgrok http 3000 --allow-ip 203.0.113.50,198.51.100.0/24

Whether that helps depends on something we cannot tell you: whether your provider publishes the addresses it delivers from and commits to them. That is a question for their documentation, and the answer differs by provider. The simpler control is the one you already have, which is that the tunnel exists only while the command is running.

Next

Run your first tunnel.

Free to start. $9 for a URL that stays. You pay for features, never for traffic.