The authenticated POST /api/webhooks route is wrapped as withAuth(async (event) => { ... }), but the body parser calls await request.json() instead of await event.request.json().
Because that ReferenceError is caught by the route's JSON-parse catch, valid authenticated webhook creation requests are incorrectly rejected as 400 { "error": "Invalid JSON" } before URL/events validation or insertion can run.
Repro from code inspection:
src/lib/api/middleware/auth.js calls the handler with { request, locals, context }.
src/app/api/webhooks/route.js destructures event.locals, but later references a non-existent request variable.
- The POST path therefore cannot parse a valid request body.
Expected: parse the JSON body from event.request, then continue existing validation and insert logic.
The authenticated
POST /api/webhooksroute is wrapped aswithAuth(async (event) => { ... }), but the body parser callsawait request.json()instead ofawait event.request.json().Because that
ReferenceErroris caught by the route's JSON-parsecatch, valid authenticated webhook creation requests are incorrectly rejected as400 { "error": "Invalid JSON" }before URL/events validation or insertion can run.Repro from code inspection:
src/lib/api/middleware/auth.jscalls the handler with{ request, locals, context }.src/app/api/webhooks/route.jsdestructuresevent.locals, but later references a non-existentrequestvariable.Expected: parse the JSON body from
event.request, then continue existing validation and insert logic.