{"record":{"id":"71904969f6d4d3f3","repo":"vercel/next.js","slug":"client-max-body-size-must-be-a-valid-number-bytes","errorCode":null,"errorMessage":"Client Max Body Size must be a valid number (bytes) or filesize format string (e.g., \"5mb\")","messagePattern":"Client Max Body Size must be a valid number \\(bytes\\) or filesize format string \\(e\\.g\\., \"5mb\"\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":1068,"sourceCode":"    userConfig.skipProxyUrlNormalize !== undefined &&\n    userConfig.skipMiddlewareUrlNormalize === undefined\n  ) {\n    result.skipMiddlewareUrlNormalize = userConfig.skipProxyUrlNormalize\n  }\n\n  // Normalize & validate experimental.proxyClientMaxBodySize\n  if (typeof result.experimental?.proxyClientMaxBodySize !== 'undefined') {\n    const proxyClientMaxBodySize = result.experimental.proxyClientMaxBodySize\n    let normalizedValue: number\n\n    if (typeof proxyClientMaxBodySize === 'string') {\n      const bytes =\n        require('next/dist/compiled/bytes') as typeof import('next/dist/compiled/bytes')\n      normalizedValue = bytes.parse(proxyClientMaxBodySize)\n    } else if (typeof proxyClientMaxBodySize === 'number') {\n      normalizedValue = proxyClientMaxBodySize\n    } else {\n      throw new Error(\n        'Client Max Body Size must be a valid number (bytes) or filesize format string (e.g., \"5mb\")'\n      )\n    }\n\n    if (isNaN(normalizedValue) || normalizedValue < 1) {\n      throw new Error('Client Max Body Size must be larger than 0 bytes')\n    }\n\n    // Store the normalized value as a number\n    result.experimental.proxyClientMaxBodySize = normalizedValue\n  }\n\n  warnOptionHasBeenMovedOutOfExperimental(\n    result,\n    'transpilePackages',\n    'transpilePackages',\n    configFileName,\n    silent","sourceCodeStart":1050,"sourceCodeEnd":1086,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L1050-L1086","documentation":"`experimental.proxyClientMaxBodySize` is normalized at config.ts:1057-1071. It accepts either a string (parsed via `bytes.parse`) or a number (bytes). Any other type (boolean, object, null-as-not-undefined is fine but a function/array/etc.) throws this error before normalization proceeds.","triggerScenarios":"Setting `experimental.proxyClientMaxBodySize: true`, `proxyClientMaxBodySize: ['5mb']`, or `proxyClientMaxBodySize: { size: 5 }`.","commonSituations":"Accidentally wrapping the value in an array or object from a templated config generator. Passing a boolean from an env-var coercion (`!!process.env.X`).","solutions":["Set the value to a number of bytes or a filesize string: `proxyClientMaxBodySize: 5_242_880` or `proxyClientMaxBodySize: '5mb'`.","If reading from an env var, coerce explicitly: `proxyClientMaxBodySize: process.env.MAX_BODY ? Number(process.env.MAX_BODY) : undefined`.","Omit the key entirely to use the default."],"exampleFix":"// before\nmodule.exports = { experimental: { proxyClientMaxBodySize: true } }\n// after\nmodule.exports = { experimental: { proxyClientMaxBodySize: '5mb' } }","handlingStrategy":"type-guard","validationCode":"const v = config.experimental?.proxyClientMaxBodySize;\nif (v !== undefined && typeof v !== 'number' && typeof v !== 'string') {\n  throw new Error('proxyClientMaxBodySize must be number or filesize string');\n}","typeGuard":"function isBodySizeInput(v: unknown): v is number | string {\n  return typeof v === 'number' || typeof v === 'string';\n}","tryCatchPattern":null,"preventionTips":["Coerce env-derived values with Number() or String() before assigning.","Avoid wrapping the value in arrays/objects in config generators."],"tags":["config","proxy","bodysizelimit","validation","next-config"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}