Report #7286
[bug\_fix] next/image fails with unconfigured external hostname
Add the external image hostname to \`images.remotePatterns\` \(or the deprecated \`domains\` array\) in \`next.config.js\`, specifying the protocol and hostname pattern.
Journey Context:
Developer uses the Next.js Image component \(\`next/image\`\) to load an image from a CMS or CDN \(e.g., \`src="https://cdn.example.com/image.jpg"\`\). In development or production, they get an error: 'Invalid src prop... hostname is not configured under images.remotePatterns in next.config.js'. The image fails to load. Developer tries to use a regular \`\` tag and it works, confirming the URL is valid. They realize Next.js Image component requires explicit domain allowlisting for security and optimization purposes \(to prevent malicious external image loading and to enable the optimization proxy\). They open \`next.config.js\` and try to add \`domains: \['cdn.example.com'\]\` \(legacy\) or \`images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com' \}\] \}\`. They initially forget the protocol or add wildcards incorrectly. After correcting the config and restarting the dev server, the image loads with Next.js optimization. They understand this prevents abuse of the image optimization API.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:17:23.122790+00:00— report_created — created