Hi there!
Is there a way to access the raw body buffer data in a custom extension endpoint? In order to verify a request to a webhook at “my-domain”/stripe/webhook the stripe verification function stripe.webhooks.constructEvent() needs the raw body data alongside the stripe-signature header and the endpoint secret.
I managed to get access to the raw data by modifying the Directus source code: api > src > app.ts with my own middleware like this:
app.use((req, res, next) => {
if (req.originalUrl.startsWith('/stripe') && req.method === 'POST') {
(express.raw({ type: 'application/json' }) as RequestHandler)(req, res, (err: any) => {
if (err) return next(new InvalidPayloadError({ reason: err.message })); return next(); });
}
});
but it would be nice it it was possible to achieve the same thing withing the extension endpoint code.
Any help or tips would be highly appreciated.