Having the same issue… I can read the “non-rawbody” but can’t read the raw body…
console.log(“Received Stripe webhook payload:”, unparsedBody); → UNDEFINED
console.log(“Received webhook payload:”, ctx.request.body); → THE STRIPE WEBHOOK CONTENT
But i can’t get it to work…
const stripe = require(‘stripe’)(process.env.STRIPE_SECRET_KEY);
const unparsed = require(“koa-body/lib/unparsed.js”);
module.exports = {
async webhook(ctx) {
const signature = ctx.request.headers[‘stripe-signature’];
const unparsedBody = ctx.request.body[unparsed];
And in my middleware:
module.exports = [
‘strapi::errors’,
‘strapi::security’,
‘strapi::cors’,
‘strapi::poweredBy’,
‘strapi::logger’,
‘strapi::query’,
{
name: ‘strapi::body’,
config: {
includeUnparsed: true,
},
}, ‘strapi::session’,
‘strapi::favicon’,
‘strapi::public’,
];