Stripe webhook not working after deploy on netlify

I’m doing stripe integration in my next.js application and then deploy my project on netlify, but after deployment my stripe webhook is not giving me proper response and giving me this error Webhook Error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?.

It is something related to raw body because stripe verification needs raw body in this step: stripe.webhooks.constructEvent( req.body, sig, endpointSecret );

How should I fix this error ?

I’ve also tried this option in my node.js backend,

// app.use(
//   bodyParser.json({
//     verify: (req, res, buf) => {
//       req.rawBody = buf;
//     },
//   })
// );

but it’s only working in local not after deploy on netlify.

Can you please help me with this ?

Have you tried searching the forums for this error? I also recommend you take a look at this documentation. Deploy notifications | Netlify Docs