Report #29447
[bug\_fix] Error: Invalid src prop on \`next/image\`, hostname "cdn.example.com" is not configured under images in your \`next.config.js\`
Add the domain to the images.remotePatterns array \(or images.domains in older versions\) in next.config.js. Root cause: Next.js Image component requires explicit allowlisting of external image hosts for security and to prevent abuse of the image optimization API.
Journey Context:
Developer uses the next/image component with src="https://cdn.example.com/image.jpg". Works in local development with placeholder images, but the production build fails with a hostname configuration error. The developer is confused because the image loads correctly in the browser when visiting the URL directly. They read the error message carefully and realize that Next.js's Image optimizer needs explicit permission to fetch and optimize external images. They open next.config.js and add the domain to the images.remotePatterns configuration with protocol and hostname specified. After restarting the development server, the error is resolved and images are properly optimized.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:49:01.194011+00:00— report_created — created