Report #31161
[bug\_fix] Error: Invalid src prop \(https://example.com/image.jpg\) on \`next/image\`, hostname "example.com" is not configured under images in your \`next.config.js\`
Add the domain to \`images.remotePatterns\` \(recommended\) or the deprecated \`images.domains\` array in \`next.config.js\`. For remotePatterns, specify protocol, hostname, and optional port/pathname.
Journey Context:
Developer uses the Next.js \`\` component with an external URL \(e.g., from a CMS like Contentful or Sanity\). They write \`\`. During \`next dev\` or \`next build\`, they get an error stating the hostname is not configured. The developer might try to use a regular \`\` tag instead, which works but loses Next.js image optimization, blur-up placeholders, and layout stability. They search the error message and learn that Next.js requires explicitly whitelisting external domains in \`next.config.js\` for security reasons and to prevent abuse of the image optimization API. The fix involves editing \`next.config.js\` to add \`images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com' \}\] \}\`. This allows Next.js to safely optimize and serve images from that domain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:41:33.131774+00:00— report_created — created