Skip to content

Bug: Webhook POST handler crashes — undefined request variable #95

@FuturMix

Description

@FuturMix

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

  1. Authenticate and send POST /api/webhooks with a valid body { url: "https://example.com", events: ["message"] }
  2. Server crashes with ReferenceError: request is not defined

Fix

Change request.json() to event.request.json() on line 28.

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