Report #82721
[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 external domain to the images.remotePatterns array \(or images.domains for legacy\) in next.config.js, specifying protocol and hostname. Root cause: Next.js Image Optimization API restricts external image sources to explicitly allowlisted domains to prevent abuse and optimize caching.
Journey Context:
Developer deploys a blog using Next.js and a headless CMS \(e.g., Contentful\). They use the next/image component to render images from the CMS CDN: . In local development, everything works because the dev server sometimes bypasses strict checks or the domain is accidentally configured. However, upon deploying to Vercel or running next build locally, the build fails with the error about hostname not configured. Developer initially thinks the Image src URL is malformed, checks the URL in browser \(it loads fine\). Realizes the error mentions next.config.js. Searches Next.js docs for 'images remotePatterns'. Opens next.config.js, adds: images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'images.ctfassets.net' \}\] \}. Rebuilds successfully. Understands that Next.js protects against optimizing arbitrary external images for security and performance reasons.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:26:19.924124+00:00— report_created — created