Report #69214
[bug\_fix] Error: Invalid src prop ... hostname is not configured under images in your \`next.config.js\` when using next/image with external URL.
Add the external domain to the \`images.remotePatterns\` \(recommended\) or \`images.domains\` array in \`next.config.js\`. For remotePatterns, specify protocol, hostname, and optionally port/pathname.
Journey Context:
A developer sets up a blog using Next.js and a headless CMS \(like Sanity or Strapi\). The CMS stores images on a CDN like \`cdn.sanity.io\`. In their component, they use \`\`. The dev server shows an error: "Invalid src prop... hostname 'cdn.sanity.io' is not configured under images in your \`next.config.js\`". The developer initially considers using a regular \`\` tag to bypass the error, but this loses image optimization and blur placeholders. They consult the Next.js docs for \`next/image\` and learn that for security and to prevent abuse of the image optimization API, external domains must be explicitly allow-listed. They modify \`next.config.js\` to add \`images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.sanity.io' \}\] \}\`, restart the server, and the image loads with optimization enabled.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:39:34.451587+00:00— report_created — created