{"record":{"id":"17603cc4108b0672","repo":"vercel/next.js","slug":"specified-basepath-basepath-has-to-be-either-an","errorCode":null,"errorMessage":"Specified basePath /. basePath has to be either an empty string or a path prefix\"","messagePattern":"Specified basePath /\\. basePath has to be either an empty string or a path prefix\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":620,"sourceCode":"      }\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 !== '/') {\n      if (result.basePath.endsWith('/')) {\n        throw new Error(\n          `Specified basePath should not end with /, found \"${result.basePath}\"`\n        )\n      }\n\n      if (result.assetPrefix === '') {","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L602-L638","documentation":"When basePath is non-empty, the value '/' is explicitly rejected because it would prefix routes with '//'. Normalization throws if `basePath === '/'`, telling you basePath must be either an empty string (default, root serving) or a real path prefix like '/docs'.","triggerScenarios":"Setting `basePath: '/'` in next.config. The check runs only when basePath !== ''.","commonSituations":"Assuming '/' means 'serve from root' (it actually means empty string). Setting basePath to the root path to 'be explicit'. Copying a trailing-slash pattern from another framework.","solutions":["Set basePath to '' (empty string) to serve from root, or omit the key","Use a real prefix like `basePath: '/app'` if you want a sub-path"],"exampleFix":"// before\nmodule.exports = { basePath: '/' }\n// after\nmodule.exports = { basePath: '' }","handlingStrategy":"validation","validationCode":"if (basePath === '/') basePath = ''","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use empty string '' for root serving, never '/'","Normalize basePath before passing to config: replace '/' with ''"],"tags":["config","base-path","routing"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}