Capítulo 413 de 456
Limits how much of a request body Next.js buffers in memory when proxy clones the body for multiple reads (both in the proxy and the underlying route handler), preventing excessive memory usage.
experimental, default 10MB. Accepts a human-readable string ('1mb') or a number of bytes.b, kb, mb, gb.import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
proxyClientMaxBodySize: '1mb',
},
}
export default nextConfig
export async function proxy(request: NextRequest) {
const body = await request.text()
console.log('Body size:', body.length)
return NextResponse.next()
}
proxy quanto depois no route handler (app/api/upload/route.ts), reaproveitando o mesmo buffer.proxy é usado no app.proxy.js também é afetado por essa config caso a extensão de página seja customizada.