## 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.

```text
createError
```

## Steps

1. Nuxt 3 server routes run on h3. Calling `readBody(event)` parses the JSON, which breaks Stripe's signature. Use `readRawBody(event)` instead: it returns the raw string (or a Buffer with a falsy encoding).

2. - `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.
- `getHeader` and `createError` are 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

```text
// 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.
