From fccf6f4de8d59be83cd32d458edd46214f23cb3e Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Sat, 11 Feb 2023 00:15:28 +0100 Subject: [PATCH] Revert "remove body parser settings for now" This reverts commit 41ce22aa1c718dde7585609da2addd75985394a0. --- packages/backend/src/server/api/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index fc6e0158d..bfbc6a3fe 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -40,7 +40,14 @@ app.use(async (ctx, next) => { app.use(formidable()); app.use( - bodyParser(), + bodyParser({ + // リクエストが multipart/form-data でない限りはJSONだと見なす + detectJSON: (ctx) => + !( + ctx.is("multipart/form-data") || + ctx.is("application/x-www-form-urlencoded") + ), + }), ); // Init multer instance