Skip to content

Hosted /api/stripe/webhook returns error after being deployed to cloudflare #519

@GKaza

Description

@GKaza

I am using a webhook to handle successful payments through Stripe in my project. While this would work locally, I get an error after I deploy with nuxthub and change the setting in Stripe to target my hosted endpoint.

The full error I get is:

POST 500 /api/stripe/webhook
[nuxt] [request error] [unhandled] [500],Class extends value #<Object> is not a constructor or null
  at chunks/routes/api/stripe/webhook.mjs:1:188650

According to docs, some librairies may not be compatible with the edge runtime yet. Even though I didn't locate the exact library causing this, this could be the case as it matches the 500 error returned. I have 3 libraries being used in my webhook code that could be causing this.
One is Stripe of course, second is supabase which I use to get final products and lastly nodemailer, used to send mail to the customer.

Steps to reproduce
Steps to reproduce the behavior:

  1. Create a basic webhook endpoint
  2. Deploy to cloudflare with nuxthub and target with stripe
  3. Trigger endpoint with a test payment
  4. See error

Expected behavior
Hosted webhook endpoint should work the same as when tested locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions