Solution skill
Stripe webhooks on Nuxt: readRawBody keeps the bytes Stripe signed
Complete solution
Shows how to fix stripe webhooks on Nuxt: readRawBody keeps the bytes Stripe signed. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "createError": use readRawBody(event) instead: it returns the raw string (or a Buffer with a falsy encoding). Nuxt 3 server routes run on h3.
createErrorSteps
- Nuxt 3 server routes run on h3. Calling
readBody(event)parses the JSON, which breaks Stripe's signature. UsereadRawBody(event)instead: it returns the raw string (or a Buffer with a falsy encoding). - -
readRawBody(event, 'utf-8')returns a string; pass a falsy encoding for a Buffer. Either works with constructEvent.
- Do not call
readBody(event)anywhere in this handler, even for logging. getHeaderandcreateErrorare auto-imported in Nuxt 3, no import needed.
When to use
You are seeing this: Calling readBody(event) parses the JSON, which breaks Stripe's signature. Use this skill when you run into "Stripe webhooks on Nuxt: readRawBody keeps the bytes Stripe signed".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Variants
Other phrasings of the same problem that show up in reports:
// server/api/webhooks/stripe.post.ts
// server/api/webhooks/stripe.post.ts
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_API_KEY_VALUE);
const signingValue = process.env.STRIPE_WEBHOOK_SIGNING_VALUE;
export default defineEventHandler(async (event) => {
const rawBody = await readRawBody(event, 'utf-8');
const sig = getHeader(event, 'stripe-signature');
let stripeEvent;
try {
stripeEvent = stripe.webhooks.constructEvent(rawBody, sig, signingValue);
} catch (err) {
throw createError({ statusCode: 400, message: 'bad signature' });
}
// switch on stripeEvent.type ...
return { received: true };
});Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
h3's readRawBody(event, encoding) reads the request body and returns the raw encoded string, or a Buffer with a falsy encoding (h3.unjs.io/utils/request, verified live). Nuxt 3 server routes run on h3 with readBody/readRawBody auto-imported. Stripe requires the raw body for constructEvent (docs.stripe.com/webhooks/signature). Verified against live docs 2026-09-26.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_Vbk5a6MwLS9NMc-HlDmsbw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Stripe webhooks on Nuxt: readRawBody keeps the bytes Stripe signed <span>— Vectle</span></a>