A Stripe webhook to a Vercel function fails with a 308 redirect
(308) ERR in the Stripe webhook delivery listShort answer
Stripe treats every redirect from a webhook URL as a failure and does not follow it. A 308 on Vercel is a permanent redirect, most often from a trailing-slash rule, a redirects entry in vercel.json, or a domain redirect between apex and www. Find the Location header with curl, then register that final URL in Stripe.
Fix it fast
1Find out which cause you have
Send a POST to the exact URL that is registered in Stripe, and read the status line and the Location header. The Location is where Vercel wants the request to go.
curl -i -X POST https://example.com/api/webhooks/stripe -H "Content-Type: application/json" -d '{}'2Match what you see, then jump to its fix
- 1
Location is your URL with a slash added or removed at the end.A trailing slash rule redirects your URLFix - 2
Location points to a different path, and vercel.json has a redirects entry that matches.A redirects rule in vercel.json matches the webhook pathFix - 3
Location has a different host: the www name instead of the apex, or the reverse.The webhook uses a domain that redirects to anotherFix
- 1
What does the error look like?
(308) ERR in the Stripe webhook delivery listHTTP/2 308
Cause 1 of 3
A trailing slash rule redirects your URL
1Check
In Next.js, URLs with a trailing slash redirect to the version without it by default, and trailingSlash: true reverses that. On Vercel, trailingSlash in vercel.json does the same with a 308: true redirects /path to /path/, false redirects /path/ to /path.
grep -rn "trailingSlash" next.config.* vercel.json2Fix
Register the webhook URL in exactly the form the app serves, with no redirect. If the project uses trailingSlash: true, add the slash to the URL in Stripe; if not, remove it.
// next.config.js
module.exports = { trailingSlash: false }
// Stripe endpoint: https://example.com/api/webhooks/stripe3Verify
The POST returns the handler's status, not 308.
curl -i -X POST https://example.com/api/webhooks/stripe -d '{}'Confirmed by vercel.com
Cause 2 of 3
A redirects rule in vercel.json matches the webhook path
1Check
Vercel redirects are permanent by default, and the status code is 308 when permanent is true. A broad source pattern can catch the webhook path.
grep -n "redirects" -A8 vercel.json2Fix
Narrow or remove the rule so the webhook path is not matched.
{
"redirects": [
{ "source": "/blog/:path*", "destination": "/news/:path*" }
]
}3Verify
Redeploy and repeat the first-step command.
curl -i -X POST https://example.com/api/webhooks/stripe -d '{}'Confirmed by vercel.com
Cause 3 of 3
The webhook uses a domain that redirects to another
1Check
Vercel domains can redirect one domain to another, for example www to the apex, and Vercel attempts a redirect between the www and non-www name automatically. Stripe's endpoint URL then points at the domain that redirects.
curl -sI https://www.example.com/api/webhooks/stripe | grep -i "^location"2Fix
Change the endpoint URL in Stripe to the domain the redirect leads to (Stripe's guidance for any 3xx: set the endpoint to the URL resolved by the redirect). Do not turn the redirect off for the whole site.
# Stripe Dashboard > Webhooks > endpoint URL
https://example.com/api/webhooks/stripe3Verify
Resend a failed event from the Dashboard; the delivery shows 200.
stripe events resend EVENT_ID --webhook-endpoint=WEBHOOK_ENDPOINT_IDConfirmed by vercel.com
How do I stop it coming back?
- Register the webhook with the final canonical URL, and keep trailing-slash settings the same on every environment.
- Test the endpoint with curl -i -X POST after every deploy that touches redirects.
- Return a 2xx quickly from the handler and do slow work after the response.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Payments
Stripe webhook: no signatures found matching the expected signature
No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?
Stripe signs the exact bytes it sends, using that endpoint's own secret.
5 causes, each with a fixPayments
Stripe Elements shows console warnings or errors in a Next.js checkout
Could not find Elements context; You need to wrap the part of your app that calls useElements() in an <Elements> provider.
Most React Stripe.js warnings come from four mistakes: calling loadStripe inside a component, using useStripe or useElements outside the Elements provider, using the objects before they have loaded, and a Content Security Policy that blocks js.stripe.com.
4 causes, each with a fixPayments
firebase deploy fails because the Stripe client has no API key
Neither apiKey nor config.authenticator provided
The Stripe client is built from a key that is empty at that moment.
3 causes, each with a fixPayments
Metadata you set on a Stripe Checkout Session is empty when you read it
event.data.object.metadata.order_id is None in the webhook handler
Stripe does not copy metadata between objects on its own.
3 causes, each with a fixPayments
Stripe says No such checkout.session when you retrieve a session
resource_missing
A resource_missing error means the ID is not visible to the key you used.
3 causes, each with a fixPayments
Stripe says there is no such token when your server uses it
livemode_mismatch
Stripe answers with a missing-resource error when the ID you send does not exist for the key you use.
3 causes, each with a fix