Report #61146
[bug\_fix] Error: Invalid src prop \(hostname is not configured under images.remotePatterns in next.config.js\)
Add the external image domain to the \`images.remotePatterns\` \(or legacy \`domains\`\) array in \`next.config.js\`. This is a security measure to prevent abuse of the image optimization API.
Journey Context:
You deploy a blog using \`next/image\` to display images from a CMS like Contentful or Sanity. In development with local images, everything works. In production, images return 400 errors with the message 'hostname is not configured'. You check the browser network tab—the image URL is correct but the Next.js optimizer is rejecting it. You realize that \`next/image\` requires explicit whitelisting of external domains to prevent attackers from using your image optimization infrastructure for their own images. You open \`next.config.js\` and add the CMS domain to \`images.remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com' \}\]\`. After restarting the server, the images load correctly through the optimization pipeline.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:07:02.166599+00:00— report_created — created