From 2c045183acdcfda07945d5c07c33d1dd325301bd Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 13 May 2025 18:41:30 +0800 Subject: [PATCH] =?UTF-8?q?multer=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app.ts b/src/app.ts index 05f1420..83cdb2f 100644 --- a/src/app.ts +++ b/src/app.ts @@ -14,7 +14,14 @@ const apps = { paths.init(); logger.info('晶灵核心初始化..'); - app.use(express.json()); + app.use((req, res, next) => { + const contentType = req.headers['content-type'] || ''; + if (contentType.includes('multipart/form-data')) { + next(); + } else { + express.json()(req, res, next); + } + }); app.use(compression()); logger.debug('成功加载 express.json() 中间件');