Webhooks
Test webhooks from services like Stripe, GitHub, and Slack on your local machine.
Why Use Trapdoor for Webhooks?
Webhook providers (Stripe, GitHub, etc.) need a public URL to send events to. During development, your localhost isn't accessible from the internet. Trapdoor creates a public URL that forwards requests to your local server.
Quick Setup
- Start your local webhook handler:
bash
# Your app listening on port 3000
node server.js- Open a trapdoor:
bash
trapdoor -port 3000 -name webhooks- Use the URL in your webhook provider:
https://webhooks.trapdoor.sh/webhookService-Specific Guides
Stripe
- Go to Stripe Dashboard
- Click "Add endpoint"
- Enter your Trapdoor URL:
https://myapp.trapdoor.sh/stripe/webhook - Select events to listen for
- Copy the webhook secret to your app
javascript
// Express.js example
app.post('/stripe/webhook', (req, res) => {
const event = req.body;
console.log('Received Stripe event:', event.type);
res.sendStatus(200);
});GitHub
- Go to your repo → Settings → Webhooks
- Click "Add webhook"
- Payload URL:
https://myapp.trapdoor.sh/github/webhook - Content type:
application/json - Select events
javascript
app.post('/github/webhook', (req, res) => {
const event = req.headers['x-github-event'];
console.log('Received GitHub event:', event);
res.sendStatus(200);
});Slack
- Go to Slack API
- Create an app → Event Subscriptions
- Request URL:
https://myapp.trapdoor.sh/slack/events - Subscribe to events
Tips
- Use a custom subdomain (-name) so your URL stays the same
- Keep the tunnel running while testing
- Check your terminal for incoming requests