If the incoming body text is not valid JSON, this could be the source of your error.
For example, "How to access request body in nextjs 13.2 route handler" uses const body = await req.text();
:
import { Webhook, WebhookRequiredHeaders } from "svix";const webhookSecret = process.env.WEBHOOK_SECRET || "";async function handler(request: Request) {const svix_id = request.headers.get("svix-id") ?? "";const svix_timestamp = request.headers.get("svix-timestamp") ?? "";const svix_signature = request.headers.get("svix-signature") ?? "";const body = await request.text(); // This gets the raw body as a stringconst sivx = new Webhook(webhookSecret);try {const payload = sivx.verify(body, {"svix-id": svix_id,"svix-timestamp": svix_timestamp,"svix-signature": svix_signature,});console.log(payload);} catch (err) {console.error('Error verifying webhook:', err);}}export const GET = handler;export const POST = handler;export const PUT = handler;