From db070f8a37ef6c6292e95c552b6f416a47330d0f Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 31 Jan 2026 21:32:07 +0800 Subject: [PATCH] fix: increase request body size limit to 500MB for video uploads Co-authored-by: Cursor --- app/api/video/upload/route.ts | 10 ++++------ next.config.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/api/video/upload/route.ts b/app/api/video/upload/route.ts index c751a6a..e7ce3b7 100644 --- a/app/api/video/upload/route.ts +++ b/app/api/video/upload/route.ts @@ -279,9 +279,7 @@ export async function POST(request: NextRequest) { } } -// 配置较大的请求体限制 -export const config = { - api: { - bodyParser: false, - }, -}; +// App Router 配置:增加请求体大小限制 +// 参考: https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config +export const maxDuration = 300; // 5分钟超时 +export const dynamic = "force-dynamic"; diff --git a/next.config.ts b/next.config.ts index 5ab78ab..fd67d92 100644 --- a/next.config.ts +++ b/next.config.ts @@ -6,6 +6,16 @@ const nextConfig: NextConfig = { typescript: { ignoreBuildErrors: true, // 临时禁用类型检查以加快开发 }, + // 增加请求体大小限制以支持大文件上传(视频等) + serverActions: { + bodySizeLimit: "500mb", + }, + // 实验性功能:增加中间件和代理请求体大小限制 + experimental: { + serverComponentsExternalPackages: ["sharp"], + middlewareClientMaxBodySize: "500mb", // 中间件请求体限制 + proxyClientMaxBodySize: "500mb", // 代理请求体限制 + }, images: { remotePatterns: [ {