fix(upload): bump middlewareClientMaxBodySize to 100mb

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ı'.
This commit is contained in:
kovakmedya
2026-05-21 21:05:33 +03:00
parent f34630de62
commit 2bf130105e
2 changed files with 8 additions and 0 deletions
+6
View File
@@ -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;
+2
View File
@@ -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 {