Report #104261
[bug\_fix] Next.js Image component error: "The requested resource isn't a valid image" or "hostname is not configured" when using external images without specifying domains in \`next.config.js\`
Add the external image hostname to the \`images.remotePatterns\` array in \`next.config.js\`. For example: \`module.exports = \{ images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'example.com' \}\] \} \}\`.
Journey Context:
I was using the Next.js \`Image\` component with a remote image from an external CDN. The image didn't load, and the console showed "The requested resource isn't a valid image". I checked the URL — it was fine. After reading the error more carefully, I saw a warning in the terminal about an unconfigured hostname. I went to \`next.config.js\` and added the domain under \`images.remotePatterns\`. That fixed it. I later learned that Next.js optimizes images by default and requires explicit opt-in for external domains to prevent abuse. Without this config, the image is not served through the optimization pipeline and fails.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-19T20:08:08.701084+00:00— report_created — created