how to access a rawBody in an endpoint #10832
Replies: 3 comments 3 replies
-
Not sure but |
Beta Was this translation helpful? Give feedback.
-
Based on https://github.com/stripe/stripe-node/blob/465c7f326daaa626028efff4c211739e1261921c/src/Webhooks.ts#L29 we want a Can you try // Uint8Array
const webhookPayload = new Uint8Array(await request.arrayBuffer()); https://stripe.com/docs/identity/handle-verification-outcomes#create-webhook or // base64 string
const webhookPayload = (new Buffer(await request.arrayBuffer())).toString('base64'); |
Beta Was this translation helpful? Give feedback.
-
I think the issue is that before the body of the request arrives to the endpoint, sveltekit it's interacting with it and then it arrives to the endpoint, is there a way we could access the body or request before sveltekit interacts with it? They have an example on how to deal with this on nextjs because I guess they have the same issue https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/nextjs/pages/api/webhooks.ts |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
To validate a request from stripe, I have to provide them the rawBody of the request, but every try throws an error.
I have tried other solutions that I read in other issues that worked for some users but I couldn't make it work
Solution with text: #3384 (comment)
Solution with buffer: #3384 (comment)
I think we have the same error #10339
Reproduction
pnpm dev
this sveltekit app repohave installed the stripe-cli and have an user to test it download stripe cli
do the login for the stripe with
stripe login
connect the cli with the server
stripe listen --forward-to http://localhost:5173/api/with-buffer
in a another terminal run a stripe event, the one I use is payment.intent
stripe trigger payment_intent.succeeded
you can also test the other method with
stripe listen --forward-to http://localhost:5173/api/with-text
Logs
System Info
Severity
blocking an upgrade
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions