Quick Fix for Clerk Webhooks + Protected Routes (Works Instantly!)
Just set up Clerk webhooks for auth, and holy cow – it’s WAY simpler than I thought! 😅 But here’s what almost broke me
Step 1: Proxy Your Localhost for Testing
You need a public URL for Clerk webhooks to hit your local machine. Just run:
npx localtunnel@latest tunnel http://localhost:3000
Copy the URL it gives you and paste it into Clerk’s webhook URL field.
Step 2: Write Your Webhook Route
Create a route (e.g., api/clerk/webhook/route.ts) and add your logic
Step 3: UNPROTECT THE WEBHOOK ROUTE!
This is where most people get stuck! If your middleware protects the webhook route, Clerk can’t reach it. Update your middleware.js:
export default authMiddleware({
publicRoutes: ['/', '/api/clerk/webhook(.*)'],
});
Boom, done this is that's simple
3
4 comments
Jyotishman Pathak
1
Quick Fix for Clerk Webhooks + Protected Routes (Works Instantly!)
University of Code
skool.com/universityofcode
You'll get Exclusive Lessons & Content, Badass Community Support & More here to elevate as a Dev!
Leaderboard (30-day)
Powered by