#fire-webhook-signature

1 messages ยท Page 1 of 1 (latest)

meager stumpBOT
daring egret
#

fire-webhook-signature

#

@balmy lintel hello! The error is quite descriptive and explains the problem

balmy lintel
#
// parse requests of content-type - application/json
app.use((req, res, next) => {
  if (req.originalUrl.startsWith("/webhook/")) {
    console.log("----------------------webhook");
    next(); // Do nothing with the body because I need it in a raw state.
  } else {
    console.log("----------------------not webhook: ");
    express.json()(req, res, next); // ONLY do express.json() if the received request is NOT a WebHook from Stripe.
  }
});
#

Understandable, but how didn't this fix it?

#

@daring egret

daring egret
#

why would this fix it specifically?

balmy lintel
#

it's also in your examples

daring egret
#

there are dozens of things that can make your Node.js environment cause this bug unfortunately

#

it can be manythings and that's what you have to debug. https://github.com/stripe/stripe-node/issues/341 has a ton of different examples which can help you fix it. I unfortunately can't tell you which one would work for you as it's so specific to your entire environment

#

also do make sure that you triple check the WebhookEndpoint's secret first to make sure that's not the problem

balmy lintel
#

Got it working, thanks

daring egret
#

what did you change?

balmy lintel
#

added express.raw({ type: "application/json" }) as a middleware

daring egret
#

gotcha, thanks for sharing. I wish it was easier. 99% of the reports are purely Node specific ๐Ÿ˜ฆ

balmy lintel
#

No worries mate, got me confused for a while myself.

#

Thanks again ๐Ÿ‘