#Buffer and Next.js 13.2

4 messages · Page 1 of 1 (latest)

solemn hawk
#

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

reef glade
#

Hi, Did you ever find a solution for this?

hexed fox
#

@reef glade @solemn hawk have you guys found a solution?

candid arrow
#

I'm out here facing the same issue, @hexed fox @reef glade or @solemn hawk did you make any progress? been stuck on this for a day.