Stripe webhook · Stripe Dashboard
401 / 403 from auth middleware or Vercel Deployment Protection
Webhook delivery failed: HTTP status code 401 (Unauthorized)What it means
Something answered before your handler ran. Stripe has no session cookie, so auth middleware rejects it or redirects it to sign-in. On Vercel, Deployment Protection (Vercel Authentication) blocks preview deployments, and sometimes production, with a 401.
Common causes
- proxy.ts / middleware.ts protects /api/* and the matcher doesn't exclude the webhook
- Vercel Deployment Protection is on for the URL Stripe calls (often a preview URL)
- Cloudflare / WAF bot protection challenges Stripe's requests
- Basic auth on a staging site
How to fix it
- Exclude /api/stripe/webhook from the middleware matcher: the Stripe signature is its authentication
- Point Stripe at your production domain, not a *.vercel.app preview URL
- Or turn off Deployment Protection for that URL, or use Vercel's Protection Bypass for Automation
- Allow Stripe's webhook IPs through your WAF if needed
export const config = {
// run everywhere except static files and the Stripe webhook
matcher: ["/((?!api/stripe/webhook|_next/static|_next/image|favicon.ico).*)"],
};curl -i -X POST https://<your-domain>/api/stripe/webhook
# expect 400 (missing signature) from your handler, not 3xx, 401, 403, 404 or 405
stripe events resend evt_... --webhook-endpoint=we_...
# we_... is the endpoint id in the Dashboard; add --live for a live-mode event
pass if curl gets 400 from your own handler, and the resent event shows a 200 delivery on the endpoint in the Dashboard.
Prompt for Cursor or Claude Code
Stripe gets 401/403 from my webhook. Find every proxy.ts/middleware.ts matcher, auth check or wrapper that runs on /api/stripe/webhook and exclude that route, keeping signature verification as its only auth. Also tell me if the URL in Stripe is a Vercel preview URL behind Deployment Protection.Not quite your error? Paste yours into the free VibeBoot Doctor or browse the Stripe webhook fixer.
next: skip the next one
Skip the setup. The VibeBoot SaaS Starter ships Stripe Checkout, the billing portal and a signature-verified webhook already wired, plus auth and a database on Next.js 16.4.3. $49, one-time.
14-day money-back guarantee · lifetime updates
Other Stripe webhook errors
$ fixed it? get the next one first
New fixes for what AI agents break, by email.
When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.