{"record":{"id":"cbccc8b642af7573","repo":"vercel/next.js","slug":"specified-images-localpatterns-should-be-an-array","errorCode":null,"errorMessage":"Specified images.localPatterns should be an Array received ${typeof images.localPatterns}.\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config","messagePattern":"Specified images\\.localPatterns should be an Array received (.+?)\\.\nSee more info here: https://nextjs\\.org/docs/messages/invalid-images-config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":655,"sourceCode":"\n      if (result.assetPrefix === '') {\n        result.assetPrefix = result.basePath\n      }\n    }\n  }\n\n  if (result?.images) {\n    const images: ImageConfig = result.images\n\n    if (typeof images !== 'object') {\n      throw new Error(\n        `Specified images should be an object received ${typeof images}.\\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`\n      )\n    }\n\n    if (images.localPatterns) {\n      if (!Array.isArray(images.localPatterns)) {\n        throw new Error(\n          `Specified images.localPatterns should be an Array received ${typeof images.localPatterns}.\\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`\n        )\n      }\n      // avoid double-pushing the same pattern if it already exists\n      if (\n        !images.localPatterns.some(\n          (pattern) =>\n            pattern.pathname === '/_next/static/media/**' &&\n            pattern.search === ''\n        )\n      ) {\n        // static import images are automatically allowed\n        images.localPatterns.push({\n          pathname: '/_next/static/media/**',\n          search: '',\n        })\n      }\n      if (","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L637-L673","documentation":"`images.localPatterns` controls which local URLs the image optimizer will fetch. It must be an array of `{ pathname, search }` glob-pattern objects. The guard at config.ts:653-658 rejects any truthy non-array value because the next step calls `.some()` / `.push()` on it. If left unset, Next.js seeds a default allowing all local paths.","triggerScenarios":"Setting `images: { localPatterns: { pathname: '/assets/**' } }` (an object instead of an array), or `localPatterns: '/assets/**'` (a string).","commonSituations":"Migrating from `remotePatterns`/`domains` and assuming localPatterns takes a single object. Misreading docs and supplying one pattern object rather than an array of one.","solutions":["Wrap your pattern in an array: `localPatterns: [{ pathname: '/assets/**', search: '' }]`.","Confirm each entry has `pathname` (string glob) and optional `search` (string).","If you want all local paths, omit localPatterns entirely so Next.js applies the default."],"exampleFix":"// before\nmodule.exports = { images: { localPatterns: { pathname: '/assets/**' } } }\n// after\nmodule.exports = { images: { localPatterns: [{ pathname: '/assets/**', search: '' }] } }","handlingStrategy":"type-guard","validationCode":"const lp = config.images?.localPatterns;\nif (lp != null && !Array.isArray(lp)) throw new Error('images.localPatterns must be an array');\nfor (const p of lp ?? []) { if (typeof p.pathname !== 'string') throw new Error('each localPattern needs a pathname string'); }","typeGuard":"type LocalPattern = { pathname: string; search?: string };\nfunction isLocalPatternsArray(v: unknown): v is LocalPattern[] {\n  return Array.isArray(v) && v.every((p) => p && typeof (p as any).pathname === 'string');\n}","tryCatchPattern":null,"preventionTips":["Always wrap individual patterns in an array literal in config.","Lint config files for `localPatterns:` followed by `{` instead of `[`."],"tags":["config","images","localpatterns","next-config"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}