Summary
The POST handler in src/app/api/webhooks/route.js references a bare request variable (line 28) that is not defined in the handler's scope. The withAuth middleware passes a single event object containing { request, locals, context }, but the handler destructures only event.locals and then tries to call request.json() — this throws ReferenceError: request is not defined.
Impact
Creating a webhook always crashes with a 500 error. The GET handler works correctly because it doesn't reference request.
Steps to Reproduce
- Authenticate and send
POST /api/webhooks with a valid body { url: "https://example.com", events: ["message"] }
- Server crashes with
ReferenceError: request is not defined
Fix
Change request.json() to event.request.json() on line 28.
Summary
The
POSThandler insrc/app/api/webhooks/route.jsreferences a barerequestvariable (line 28) that is not defined in the handler's scope. ThewithAuthmiddleware passes a singleeventobject containing{ request, locals, context }, but the handler destructures onlyevent.localsand then tries to callrequest.json()— this throwsReferenceError: request is not defined.Impact
Creating a webhook always crashes with a 500 error. The
GEThandler works correctly because it doesn't referencerequest.Steps to Reproduce
POST /api/webhookswith a valid body{ url: "https://example.com", events: ["message"] }ReferenceError: request is not definedFix
Change
request.json()toevent.request.json()on line 28.