{"record":{"id":"26f1eee95c606131","repo":"vercel/next.js","slug":"specified-images-remotepatterns-should-be-an-array","errorCode":null,"errorMessage":"Specified images.remotePatterns should be an Array received ${typeof images.remotePatterns}.\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config","messagePattern":"Specified images\\.remotePatterns 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":698,"sourceCode":"        // static import images are automatically allowed\n        images.localPatterns.push({\n          pathname: '/_next/static/immutable/media/**',\n          search: '',\n        })\n      }\n    } else {\n      // All paths are not allowed for a search query by default.\n      images.localPatterns = [\n        {\n          pathname: '**',\n          search: '',\n        },\n      ]\n    }\n\n    if (images.remotePatterns) {\n      if (!Array.isArray(images.remotePatterns)) {\n        throw new Error(\n          `Specified images.remotePatterns should be an Array received ${typeof images.remotePatterns}.\\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`\n        )\n      }\n\n      // We must convert URL to RemotePattern since URL has a colon in the protocol\n      // and also has additional properties we want to filter out. Also, new URL()\n      // accepts any protocol so we need manual validation here.\n      images.remotePatterns = images.remotePatterns.map(\n        ({ protocol, hostname, port, pathname, search }) => {\n          const proto = protocol?.replace(/:$/, '')\n          if (!['http', 'https', undefined].includes(proto)) {\n            throw new Error(\n              `Specified images.remotePatterns must have protocol \"http\" or \"https\" received \"${proto}\".`\n            )\n          }\n          return {\n            protocol: proto as 'http' | 'https' | undefined,\n            hostname,","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L680-L716","documentation":"`images.remotePatterns` defines remote hosts _next/image is allowed to optimize and must be an array of pattern objects. The check at config.ts:696-701 rejects truthy non-arrays because the code immediately calls `.map()` over entries to normalize protocol/host/port. An unset value is fine (no remote hosts); only a wrong-typed value throws.","triggerScenarios":"Setting `images: { remotePatterns: { hostname: 'cdn.com' } }` (single object) or `remotePatterns: 'cdn.com'` (string).","commonSituations":"Confusing remotePatterns (array of structured objects) with the deprecated `domains` (array of strings). Copying a single example object from docs without wrapping it in `[ ]`.","solutions":["Wrap remote patterns in an array: `remotePatterns: [{ protocol: 'https', hostname: 'cdn.example.com' }]`.","Use `domains: ['cdn.example.com']` only if you need the legacy simpler form.","Drop the key entirely to disable remote optimization."],"exampleFix":"// before\nmodule.exports = { images: { remotePatterns: { hostname: 'cdn.example.com' } } }\n// after\nmodule.exports = { images: { remotePatterns: [{ protocol: 'https', hostname: 'cdn.example.com' }] } }","handlingStrategy":"type-guard","validationCode":"const rp = config.images?.remotePatterns;\nif (rp != null && !Array.isArray(rp)) throw new Error('images.remotePatterns must be an array');\nfor (const p of rp ?? []) { if (typeof p.hostname !== 'string') throw new Error('each remotePattern needs a hostname string'); }","typeGuard":"type RemotePattern = { protocol?: 'http' | 'https'; hostname: string; port?: string; pathname?: string; search?: string };\nfunction isRemotePatternsArray(v: unknown): v is RemotePattern[] {\n  return Array.isArray(v) && v.every((p) => p && typeof (p as any).hostname === 'string');\n}","tryCatchPattern":null,"preventionTips":["Distinguish remotePatterns (array of objects) from the legacy domains (array of strings).","Wrap example objects in `[ ]` when copying from docs."],"tags":["config","images","remotepatterns","next-config"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}