Adds Next.js App Router example for Webhook signing#2245
Adds Next.js App Router example for Webhook signing#2245rhijjawi wants to merge 4 commits intostripe:masterfrom
Conversation
|
Hi @rhijjawi , very sorry for the delay here, and thank you for contributing! We'll review and get back to you with any questions we may have. One quick q out of the gate: can you help me understand what about the linked Stripe Docs example doesn't work on App Router? |
|
Heyo @jar-stripe! There's not a huge difference, just a different implementation because the Pages Router example of Buffer did not work as expected. |
Accidentally left in a personal library reference in the code that would cause the example to fail.
| throw new Error("Invalid Signature") | ||
| } | ||
| try { | ||
| const body = Uint8Array.from(await buffer(req)) as Buffer<ArrayBufferLike> |
There was a problem hiding this comment.
Why does this buffer have to be Uint8Array? Why can't we have something similar to https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/nextjs/pages/api/webhooks.ts#L56-L70
|
Hey @rhijjawi, thanks for the patience here! we're doing some final checks to match some other Next.js examples we have and then I'll get this merged this week! |
|
Echoing what Jonathan said - thank you for opening this PR and spurring us to take a closer look at our examples. We'll hopefully get that mereged. Apologies for the runaround here. 😅 If it's useful, we've also got an example in the Next.js repo itself: vercel/next.js | examples/with-stripe-typescript/.../route.ts. Between those two, we'll hopefully have enough examples to go on. Thank you! |
Addresses the following issue: #2100
Why?
Stripe Docs - The linked doc does not work on App Router, so I decided to fix it
What?
examples/webhook-signing/nextjs/app/api/webhooks/route.tsSee Also
None.