79473055

Date: 2025-02-27 14:58:57
Score: 1
Natty:
Report link

If you are using Next JS Route Handler / Pages then just use req.text() for payload.

    // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { NextResponse } from "next/server"
import Stripe from "stripe"
const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET_KEY
// import { db } from "../firebase"
import { headers } from "next/headers"
export const config = { api: { bodyParser: false } }
export async function POST(req, res) {
  const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)
  const sig = (await headers()).get("stripe-signature")
  const payload = await req.text()

How to access request body in nextjs 13.2 route handler

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: AKSHAY BHOPANI