Guides

Stripe webhook signature verification failed in Next.js: the fix

By Fixplain. Updated 16 Nov 2026. Stripe, Next.js, Webhooks.

Error message: No signatures found matching the expected signature for payload

Stripe signs every webhook it sends. Your server recomputes the signature from the exact bytes it received and your endpoint's secret. If either one differs by a single character, constructEvent throws this error. In practice, it's almost always one of four things.

1. The body was parsed before verification

This is the most common cause. req.json() turns the body into an object; turning it back into a string with JSON.stringify changes spacing and key order, so the signature no longer matches. Read the body as raw text instead:

// app/api/stripe/webhook/route.ts
import Stripe from "stripe";

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);

export async function POST(req: Request) {
  const body = await req.text(); // raw, untouched
  const signature = req.headers.get("stripe-signature");
  if (!signature) return new Response("Missing signature", { status: 400 });

  let event: Stripe.Event;
  try {
    event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!);
  } catch (err) {
    return new Response("Bad signature", { status: 400 });
  }

  if (event.type === "checkout.session.completed") {
    // fulfil the order here
  }
  return Response.json({ received: true });
}

On the old Pages Router, also turn off the built-in body parser with export const config = { api: { bodyParser: false } } and read the raw stream.

2. You're using the wrong signing secret

Every webhook endpoint has its own secret starting with whsec_. Check which one you need:

  • Stripe CLI (stripe listen --forward-to localhost:3000/api/stripe/webhook) prints its own secret when it starts. That's the one for local development.
  • The endpoint in the Dashboard has a different secret. That's the one for production.
  • Test mode and live mode endpoints have different secrets too.

After changing an environment variable on Netlify or Vercel, redeploy. Running builds don't pick up new values.

3. Something between Stripe and your code changes the request

  • A redirect, for example example.com → www.example.com or adding a trailing slash. Stripe doesn't follow redirects for webhooks, so register the final URL exactly.
  • Middleware that rewrites the request or requires login. Exclude the webhook path from auth middleware.
  • A proxy or framework plugin that decodes or re-encodes the body.

4. The secret has stray characters

A space or a line break copied along with the secret is enough to break it. Print its length on the server (never the value) and compare it with the dashboard.

Quick checklist

  1. await req.text(), not req.json(), before constructEvent.
  2. The secret matches where the events come from: CLI, test endpoint or live endpoint.
  3. The endpoint URL doesn't redirect, and middleware skips it.
  4. You redeployed after changing environment variables.

In the Dashboard, under Developers → Webhooks → your endpoint, each delivery attempt shows the response your server returned, which tells you whether your code ran at all.