{"record":{"id":"0d6a68e03a451f03","repo":"vercel/next.js","slug":"specified-basepath-is-not-a-string-found-type","errorCode":null,"errorMessage":"Specified basePath is not a string, found type \"${typeof result.basePath}\"","messagePattern":"Specified basePath is not a string, found type \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":613,"sourceCode":"          'Specified \"redirects\" will not automatically work with \"output: export\". See more info here: https://nextjs.org/docs/messages/export-no-custom-routes'\n        )\n      }\n      if (result.headers) {\n        Log.warn(\n          'Specified \"headers\" will not automatically work with \"output: export\". See more info here: https://nextjs.org/docs/messages/export-no-custom-routes'\n        )\n      }\n    }\n  }\n\n  if (typeof result.assetPrefix !== 'string') {\n    throw new Error(\n      `Specified assetPrefix is not a string, found type \"${typeof result.assetPrefix}\" https://nextjs.org/docs/messages/invalid-assetprefix`\n    )\n  }\n\n  if (typeof result.basePath !== 'string') {\n    throw new Error(\n      `Specified basePath is not a string, found type \"${typeof result.basePath}\"`\n    )\n  }\n\n  if (result.basePath !== '') {\n    if (result.basePath === '/') {\n      throw new Error(\n        `Specified basePath /. basePath has to be either an empty string or a path prefix\"`\n      )\n    }\n\n    if (!result.basePath.startsWith('/')) {\n      throw new Error(\n        `Specified basePath has to start with a /, found \"${result.basePath}\"`\n      )\n    }\n\n    if (result.basePath !== '/') {","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L595-L631","documentation":"`basePath` must be a string (or undefined). After config merge, normalization throws if `typeof result.basePath !== 'string'`, catching numbers, objects, booleans, etc. before the basePath is used to prefix every route.","triggerScenarios":"Setting `basePath: 123`, `basePath: true`, or `basePath: { prefix: '/docs' }`. Checked after the assetPrefix check in loadConfig.","commonSituations":"Reading basePath from a non-string env var. Constructing basePath conditionally and leaving a truthy non-string. Accidentally assigning an object.","solutions":["Set basePath to a string path like `basePath: '/docs'`","Omit basePath to default to '' (root)","Coerce safely: `basePath: typeof env === 'string' ? env : undefined`"],"exampleFix":"// before\nmodule.exports = { basePath: 123 }\n// after\nmodule.exports = { basePath: '/docs' }","handlingStrategy":"type-guard","validationCode":"if (basePath !== undefined && typeof basePath !== 'string') {\n  throw new TypeError('basePath must be a string')\n}","typeGuard":"const isBasePath = (v: unknown): v is string | undefined =>\n  v === undefined || typeof v === 'string'","tryCatchPattern":null,"preventionTips":["Validate env-sourced basePath type before assignment","Type config against NextConfig so TS rejects non-string basePath"],"tags":["config","base-path","type-safety","routing"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}