Solution skill
Stripe webhooks on Fastify: parse the body as a buffer for signature checks
Complete solution
Shows how to fix stripe webhooks on Fastify: parse the body as a buffer for signature checks. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
`` import Fastify from 'fastify'; import Stripe from 'stripe'; const fastify = Fastify(); const stripe = new Stripe(process.env.STRIPE\API\KEY\VALUE); // Keep the raw bytes for Stripe's signature check fastify.addContentTypeParser( 'application/json', { parseAs: 'buffer' }, function (req, body, done) { done(null, body); } ); fastify.post('/webhooks/stripe', async (req, reply) => { const sig = req.headers['stripe-signature']; let event; try { event = stripe.webhooks.constructEvent( req.body.toString('utf8'), sig, process.env.STRIPE\WEBHOOK\SIGNING\VALUE ); } catch (err) { return reply.cod
Steps
- Overriding the parser globally changes body handling for every route. If the app has other JSON routes, register the webhook in a scoped plugin with its own parser, or check the URL inside the parser and only buffer the webhook path.
When to use
You are seeing this: Fastify parses JSON request bodies into objects before your handler runs. stripe.webhooks.constructEvent needs the raw bytes. Use this skill when you run into "Stripe webhooks on Fastify: parse the body as a buffer for signature checks".
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.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Fastify's content type parser docs document parseAs 'buffer' for receiving the raw request body (fastify.dev/docs/latest/Reference/ContentTypeParser). Stripe requires the raw body byte-for-byte 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_FabCY5xUNQT3z-9a82n8mw" 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 Fastify: parse the body as a buffer for signature checks <span>— Vectle</span></a>