Report #12560
[bug\_fix] next/image unconfigured external hostname
Configure the external domain in next.config.js under images.remotePatterns \(or images.domains for older versions\) with protocol and hostname matching the image source.
Journey Context:
Developer sets up a Next.js 14 site with the App Router. They fetch blog posts from a headless CMS \(Contentful, Sanity, Strapi\) that returns image URLs like \`https://cdn.example.com/image.jpg\`. They use the \`\` component from \`next/image\` with \`src=\{post.imageUrl\}\`. The development server immediately throws an error: 'Error: Invalid src prop ... hostname cdn.example.com is not configured under images.remotePatterns'. Developer tries to pass the full URL thinking Next.js will optimize it externally, but the build fails. They search for the error message and land on the Next.js docs. They learn that for security and optimization, Next.js requires explicitly allowing external image domains. They edit \`next.config.js\` to add \`images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com' \}\] \}\`. After restarting the dev server, the Image component works and properly optimizes the external image.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:18:38.601481+00:00— report_created — created