Report #104504
[bug\_fix] Invalid src prop for Next.js Image component with external URL
Configure the external domain in \`next.config.js\` under \`images.remotePatterns\` \(or \`images.domains\` for older versions\). For example: \`remotePatterns: \[\{ protocol: 'https', hostname: 'example.com' \}\]\`. The root cause is that Next.js Image optimization requires explicit allowlisting of external image hosts for security and optimization purposes.
Journey Context:
I used the Next.js \`Image\` component to display user avatars from an external CDN \(e.g., gravatar.com\). In development, it worked fine, but in production I got an error: 'The requested resource isn't a valid image' or 'Invalid src prop'. I checked the URL—it was correct. Then I remembered that Next.js optimizes images and needs to know which external domains are allowed. I added the domain to \`images.remotePatterns\` in \`next.config.js\`. After restarting the server, the images loaded. The journey involved reading the Next.js Image component documentation and realizing that the error is a security feature, not a bug.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-30T20:03:45.538867+00:00— report_created — created