#fire-webhook-signature
1 messages ยท Page 1 of 1 (latest)
fire-webhook-signature
@balmy lintel hello! The error is quite descriptive and explains the problem
// 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
why would this fix it specifically?
https://github.com/stripe/stripe-node/issues/341 you can read through this. Sadly Node.js makes this extremely hard and there are dozens of edge-cases and solutions specific to your environment
because I am not parsing the body in case of a webhook?
it's also in your examples
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
Got it working, thanks
what did you change?
added express.raw({ type: "application/json" }) as a middleware
- this
both together worked
gotcha, thanks for sharing. I wish it was easier. 99% of the reports are purely Node specific ๐ฆ