Skip to content

POST /api/webhooks rejects valid JSON because request is undefined in withAuth handler #86

@quappefeeder

Description

@quappefeeder

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:

  1. src/lib/api/middleware/auth.js calls the handler with { request, locals, context }.
  2. src/app/api/webhooks/route.js destructures event.locals, but later references a non-existent request variable.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions