Report #30817
[bug\_fix] Invalid src prop ... hostname is not configured under images in your \`next.config.js\`
Add the external domain to the \`images.remotePatterns\` \(recommended for security\) or \`images.domains\` array in \`next.config.js\`. For example: \`images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com', pathname: '/images/\*\*' \}\] \}\`
Journey Context:
Developer is building a blog using Next.js and a headless CMS \(like Contentful or Sanity\). They use the \`next/image\` component to optimize images served from the CMS CDN: \`\`. In development mode \(\`next dev\`\), the image loads and Next.js shows a warning about the unconfigured domain. However, when they deploy to production \(Vercel\) or run \`next build\` locally, the build fails with the error: "hostname is not configured under images in your next.config.js". The developer is confused because "it's just an image URL". They try using a regular \`\` tag which works but loses image optimization benefits. They realize that Next.js Image component requires explicit domain whitelisting for security \(to prevent abuse of the image optimization API\) and caching. They edit \`next.config.js\` to add \`images: \{ domains: \['cdn.example.com'\] \}\` \(or the newer \`remotePatterns\` for protocol/path matching\). The build succeeds and the image is properly optimized in production.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:06:29.546892+00:00— report_created — created