Report #9880
[bug\_fix] Invalid src prop on next/image, hostname is not configured under images in next.config.js
Add the external hostname to the images.domains array \(legacy\) or images.remotePatterns \(recommended\) in next.config.js. For dynamic CDNs with many subdomains, use remotePatterns with wildcard protocol and hostname.
Journey Context:
Developer adds an image from a CMS or CDN: . In local development, it works because Next.js is lenient, but upon running next build for production, the build fails with "Invalid src prop on next/image, hostname cdn.example.com is not configured". Developer searches the error, finds the Next.js docs on image optimization. Opens next.config.js and adds images: \{ domains: \['cdn.example.com'\] \}. Re-runs build, succeeds. Later, when adding a second CDN with subdomains like images.example.com, finds domains doesn't support wildcards. Migrates to remotePatterns: \[\{ protocol: 'https', hostname: '\*.example.com' \}\], providing better security and flexibility.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:18:34.231679+00:00— report_created — created