Report #10304
[bug\_fix] Invalid src prop \(hostname is not configured under images.domains in next.config.js\)
Add the external domain to images.domains or images.remotePatterns in next.config.js. Root cause: Next.js Image Optimization API must whitelist external hostnames to prevent abuse and ensure security when optimizing images from third-party CDNs.
Journey Context:
You integrate a headless CMS \(Contentful, Sanity, or Shopify\) and use next/image with src=\{product.imageUrl\} pointing to the CMS CDN \(e.g., images.ctfassets.net\). In development with local images, everything works. In production or when using the real CMS data, the image fails to load and the console shows "Error: Invalid src prop \(hostname 'images.ctfassets.net' is not configured under images.domains in next.config.js\)". You try using a regular img tag which works but loses optimization and causes performance issues. After reading the next/image documentation, you understand that Next.js requires explicitly whitelisting external image domains for security. You add the domain to next.config.js: images: \{ domains: \['images.ctfassets.net'\] \} or use the newer remotePatterns syntax for wildcard support.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:18:22.786462+00:00— report_created — created