vercel/next.js · error
Config options `experimental.proxyClientMaxBodySize` and `ex
Error message
Config options `experimental.proxyClientMaxBodySize` and `experimental.middlewareClientMaxBodySize` cannot be set at the same time. Please use `experimental.proxyClientMaxBodySize` instead.
What it means
This version of Next.js aliases the older `experimental.middlewareClientMaxBodySize` to the newer `experimental.proxyClientMaxBodySize` (proxy is the renamed middleware layer). The check at config.ts:971-979 forbids setting both at once because the aliasing logic would otherwise conflict over which value wins. Only one source of truth is allowed.
Source
Thrown at packages/next/src/server/config.ts:976
if (typeof bodySizeLimit === 'number') {
value = bodySizeLimit
} else {
value = bytes.parse(bodySizeLimit)
}
if (value === null || isNaN(value) || value < 1) {
throw new Error(
'Server Actions Size Limit must be a valid number or filesize format larger than 1MB: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit'
)
}
}
// Throw if both Middleware and Proxy config are set.
if (
userConfig.experimental?.proxyClientMaxBodySize !== undefined &&
userConfig.experimental?.middlewareClientMaxBodySize !== undefined
) {
throw new Error(
'Config options `experimental.proxyClientMaxBodySize` and `experimental.middlewareClientMaxBodySize` cannot be set at the same time. Please use `experimental.proxyClientMaxBodySize` instead.'
)
}
if (
userConfig.experimental?.proxyPrefetch !== undefined &&
userConfig.experimental?.middlewarePrefetch !== undefined
) {
throw new Error(
'Config options `experimental.proxyPrefetch` and `experimental.middlewarePrefetch` cannot be set at the same time. Please use `experimental.proxyPrefetch` instead.'
)
}
if (
userConfig.experimental?.externalProxyRewritesResolve !== undefined &&
userConfig.experimental?.externalMiddlewareRewritesResolve !== undefined
) {
throw new Error(
'Config options `experimental.externalProxyRewritesResolve` and `experimental.externalMiddlewareRewritesResolve` cannot be set at the same time. Please use `experimental.externalProxyRewritesResolve` instead.'
)View on GitHub (pinned to 0ae8c72462)
Solutions
- Remove `experimental.middlewareClientMaxBodySize` and keep only `experimental.proxyClientMaxBodySize`.
- Confirm the value is correct for your deployment (it caps the body size of proxied client requests).
- Re-run the build to ensure no other alias conflicts remain.
Example fix
// before
module.exports = { experimental: { proxyClientMaxBodySize: '5mb', middlewareClientMaxBodySize: '5mb' } }
// after
module.exports = { experimental: { proxyClientMaxBodySize: '5mb' } } Defensive patterns
Strategy: validation
Validate before calling
const e = config.experimental ?? {};
if (e.proxyClientMaxBodySize !== undefined && e.middlewareClientMaxBodySize !== undefined) {
throw new Error('set only experimental.proxyClientMaxBodySize');
} Prevention
- During upgrades, grep config for `middlewareClientMaxBodySize` and remove it.
- Keep a migration checklist of renamed experimental keys.
When it happens
Trigger: Setting both `experimental.proxyClientMaxBodySize` and `experimental.middlewareClientMaxBodySize` to any value (including undefined check is `!== undefined`, so explicitly setting either triggers it).
Common situations: Upgrading Next.js and partially migrating config (added the new key without removing the old one). Copying a config snippet that uses the old name into a project that already uses the new name.
Related errors
- Config options `experimental.proxyPrefetch` and `experimenta
- Config options `experimental.externalProxyRewritesResolve` a
- Config options `skipProxyUrlNormalize` and `skipMiddlewareUr
- Client Max Body Size must be a valid number (bytes) or files
- Client Max Body Size must be larger than 0 bytes
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/82ddd87321d2d7b6.
Report an issue: GitHub.