Stripe webhook · build / deploy
Static export can't run API routes
Error: export const dynamic = "force-static"/ output: export ... route /api/stripe/webhook cannot be exported · 405 Method Not AllowedWhat it means
With output: "export" Next.js produces only static files. A POST route handler that verifies signatures needs a server or a function runtime, so on a static host the webhook either fails the build or returns 404/405.
Common causes
- output: "export" in next.config
- Hosting on a static-only host (GitHub Pages, plain S3, a Pages project with no functions)
How to fix it
- Remove output: "export" and deploy to a host that runs Next.js (Vercel, Node, Docker, OpenNext on Cloudflare)
- Or keep the site static and run the webhook as a separate function / Worker
- Then register that function's URL in Stripe
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 webhook function instead of 404 or 405, and the resent event shows a 200 delivery.
Prompt for Cursor or Claude Code
My Next.js app uses a static export but needs a Stripe webhook. Explain the options for this repo: drop output: "export" and deploy to a Next.js-capable host, or move the webhook into a separate serverless function / Worker. Recommend one and list the exact changes.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.