{"record":{"id":"f949e8e1ce9230cb","repo":"vercel/next.js","slug":"specified-assetprefix-is-not-a-string-found-type","errorCode":null,"errorMessage":"Specified assetPrefix is not a string, found type \"${typeof result.assetPrefix}\" https://nextjs.org/docs/messages/invalid-assetprefix","messagePattern":"Specified assetPrefix is not a string, found type \"(.+?)\" https://nextjs\\.org/docs/messages/invalid-assetprefix","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":607,"sourceCode":"        Log.warn(\n          'Specified \"rewrites\" 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.redirects) {\n        Log.warn(\n          '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('/')) {","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L589-L625","documentation":"`assetPrefix` must be a string (or undefined to accept the default). After merging defaults with user config, normalization throws if `typeof result.assetPrefix !== 'string'`. This catches non-string values like numbers, objects, or booleans before they reach the asset URL builder.","triggerScenarios":"Setting `assetPrefix: 123`, `assetPrefix: { cdn: 'https://...' }`, or `assetPrefix: true`. Triggered after the config merge in loadConfig.","commonSituations":"Passing a CDN URL loaded from a number-typed env var. Storing assetPrefix in an object and forgetting to dereference. Boolean flag meant to enable CDN.","solutions":["Set assetPrefix to a string URL: `assetPrefix: 'https://cdn.example.com'`","Omit assetPrefix to use the default","Coerce from env: `assetPrefix: typeof env === 'string' ? env : undefined`"],"exampleFix":"// before\nmodule.exports = { assetPrefix: { url: 'https://cdn.example.com' } }\n// after\nmodule.exports = { assetPrefix: 'https://cdn.example.com' }","handlingStrategy":"type-guard","validationCode":"if (assetPrefix !== undefined && typeof assetPrefix !== 'string') {\n  throw new TypeError('assetPrefix must be a string')\n}","typeGuard":"const isAssetPrefix = (v: unknown): v is string | undefined =>\n  v === undefined || typeof v === 'string'","tryCatchPattern":null,"preventionTips":["Coerce env-derived assetPrefix: `assetPrefix: typeof v === 'string' ? v : undefined`","Type your config object against NextConfig"],"tags":["config","asset-prefix","type-safety"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}