Report #14359
[bug\_fix] Invalid src prop on next/image, hostname is not configured under images in your next.config.js
Add the domain to images.remotePatterns \(or images.domains in older versions\) in next.config.js. Root cause: Next.js Image component requires explicit domain allowlisting for external images to prevent abuse and enable optimization; the image loader won't fetch from unconfigured hosts.
Journey Context:
You're building a blog that pulls featured images from a headless CMS like Contentful or Sanity. You use the Next.js Image component: . In development, you immediately see an error overlay: "Invalid src prop on next/image, hostname 'cdn.example.com' is not configured under images in your next.config.js". The image fails to load, showing a broken icon or the alt text. You check the browser network tab and see 400 Bad Request errors from the \`/\_next/image\` endpoint. You initially think the src URL is malformed, but copying it directly into the browser loads the image fine. You search the error message and land on the Next.js Image documentation. You learn that for security and performance optimization \(image resizing, WebP conversion\), Next.js maintains an allowlist of domains from which it will fetch and optimize images. Without this, the Image component refuses to fetch external URLs to prevent potential abuse of the image optimization service. You open your next.config.js \(or next.config.mjs\) and add the configuration: images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com' \}\] \} \(or the older domains array for Next.js 12/13\). You restart the development server. The error disappears and the image loads correctly because Next.js now recognizes the domain and passes the src to the image optimization loader at \`/\_next/image\`, which fetches, optimizes, and caches the image from the CDN.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:19:52.789177+00:00— report_created — created