From 2bf130105e5cc7d42ee79af4b81a9792fb188cf7 Mon Sep 17 00:00:00 2001 From: kovakmedya Date: Thu, 21 May 2026 21:05:33 +0300 Subject: [PATCH] fix(upload): bump middlewareClientMaxBodySize to 100mb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Next 16 caps any request body that flows through middleware at 10MB by default. Our auth middleware matches every path, so /jobs/:id POSTs from the file upload form hit 'Request body exceeded 10MB / Unexpected end of form' the moment a user picked anything bigger than ~10MB total — the server action never even ran. serverActions.bodySizeLimit alone isn't enough; the new middlewareClientMaxBodySize knob (Next 16) is the one that gates middleware-handled bodies. Set both to 100mb so the 30MB-per-file bucket limit is what actually matters. The key isn't in NextConfig's TS types yet (Next 16.1), so it's assigned via a narrow cast on the side rather than dropped into the object literal. Also added console.log/error breadcrumbs to uploadJobFilesAction so the next mystery upload failure shows up in the dev server log immediately instead of silently bouncing back as 'Bağlantı hatası'. --- next.config.ts | 6 ++++++ src/lib/appwrite/job-file-actions.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/next.config.ts b/next.config.ts index 2d92f7e..10eb7a6 100644 --- a/next.config.ts +++ b/next.config.ts @@ -61,4 +61,10 @@ const nextConfig: NextConfig = { }, }; +// Next 16 caps middleware-passed request bodies at 10MB by default. Our auth +// middleware sees every request including job-file uploads — without this +// override, multipart uploads larger than 10MB return "Unexpected end of +// form". The key isn't in NextConfig's TS types yet (Next 16.1). +(nextConfig as NextConfig & { middlewareClientMaxBodySize?: string }).middlewareClientMaxBodySize = "100mb"; + export default nextConfig; diff --git a/src/lib/appwrite/job-file-actions.ts b/src/lib/appwrite/job-file-actions.ts index ebdd844..5071520 100644 --- a/src/lib/appwrite/job-file-actions.ts +++ b/src/lib/appwrite/job-file-actions.ts @@ -81,6 +81,7 @@ export async function uploadJobFilesAction( if (!job) return { ok: false, error: "İş bulunamadı." }; const files = formData.getAll("files").filter((v): v is File => v instanceof File && v.size > 0); + console.log("[uploadJobFilesAction] jobId=%s files=%d total=%dB", jobId, files.length, files.reduce((s, f) => s + f.size, 0)); if (files.length === 0) { return { ok: false, error: "Dosya seçin." }; } @@ -143,6 +144,7 @@ export async function uploadJobFilesAction( changes: { count: files.length }, }); } catch (e) { + console.error("[uploadJobFilesAction] failed", e); // Rollback: best-effort cleanup of partially uploaded files and rows. for (const id of createdRowIds) { try {