From 9bb59d497e72ce40a00d43154f368d75b10f7536 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 5 Nov 2025 17:17:58 +0000 Subject: [PATCH] Use proper raw body middleware for Discord endpoint cgen-90c43c93d3c04e718da25f8e3141c230 --- server/index.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/server/index.ts b/server/index.ts index ee19dfc8..5c97de71 100644 --- a/server/index.ts +++ b/server/index.ts @@ -11,17 +11,12 @@ export function createServer() { // Middleware app.use(cors()); - // Capture raw body for Discord signature verification - app.use((req, res, next) => { - let rawBody = ''; - req.on('data', (chunk) => { - rawBody += chunk.toString('utf8'); - }); - req.on('end', () => { - (req as any).rawBody = rawBody; - next(); - }); - }); + // Discord endpoint needs raw body for signature verification + app.post( + "/api/discord/interactions", + express.raw({ type: "application/json" }), + handleDiscordInteractions + ); app.use(express.json()); app.use(express.urlencoded({ extended: true }));