Files
lab/next.config.ts
T
kovakmedya 2bf130105e 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ı'.
2026-05-21 21:05:33 +03:00

71 lines
1.7 KiB
TypeScript

import type { NextConfig } from "next";
const nextConfig: NextConfig = {
experimental: {
optimizePackageImports: ["lucide-react", "@radix-ui/react-icons"],
serverActions: {
// Job files bucket caps individual files at 30MB; raise overall body
// limit to allow batch uploads.
bodySizeLimit: "100mb",
},
},
turbopack: {},
// Image optimization
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'ui.shadcn.com',
},
{
protocol: 'https',
hostname: 'images.unsplash.com',
},
],
formats: ['image/webp', 'image/avif'],
},
// Headers for better security and performance
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-Frame-Options',
value: 'DENY',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin',
},
],
},
];
},
// Redirects for better SEO
async redirects() {
return [
{
source: '/home',
destination: '/dashboard',
permanent: true,
},
];
},
};
// 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;