I am trying to migrate to Next.js 13.2. Most things are working fine already however, I am having an issue with a Stripe constructEvent method which works in Next 12 but not 13 with the new appDirectory.
My issue is that in 12, I did something similar to this:
const getEventFromHeader = async (req: NextApiRequest): Promise<Stripe.DiscriminatedEvent> => {
const buf = await buffer(req);
const sig = req.headers["stripe-signature"];
return client.webhooks.constructEvent(
buf,
sig!,
STRIPE_WEBHOOK_SECRET
) as Stripe.DiscriminatedEvent;
};
However, this doesn't work anymore because the req variable is now Request and if I pass it to buffer I get an error that buffer is expecting an IncomingMessage type.
In my route.ts I still have this:
export const config = {
api: {
bodyParser: false,
},
};
Which I am not sure if it's respected anymore or not.
Any help would be great.
Thanks