Hi Directus community,
I’m trying to implement a Stripe webhook endpoint inside Directus, and I need access to the raw request body so I can verify the webhook signature with stripe.webhooks.constructEvent()
.
I tried adding this hook middleware:
import { defineHook } from "@directus/extensions-sdk";
import express from "express";
export default defineHook(({ init }) => {
init("middlewares.before", async ({ app }) => {
app.use(
express.json({
verify: (req, res, buf) => {
if (req.originalUrl.startsWith("/stripe-response")) {
req.rawBody = buf.toString("utf8");
}
},
})
);
});
});
After implementing the above hook i get the following error on all extension endpoint