Report #92377
[bug\_fix] Invalid src prop on next/image: hostname is not configured
Add the external image hostname to next.config.js under the images.remotePatterns array \(or images.domains for older Next.js versions\). Must specify protocol \(https\) and hostname; optionally port and pathname. Root cause: The Next.js Image Optimization API requires explicit allowlisting of external domains to prevent abuse of the image optimization service and to ensure security.
Journey Context:
Developer connects a CMS \(Contentful, Sanity, Strapi\) or external CDN to their Next.js app. They copy an image URL from the CMS and paste it into the src prop of next/image. The dev server immediately throws an error: 'Invalid src prop... hostname is not configured'. Developer recognizes they need to whitelist the domain. They go to next.config.js and add the domain to an array called 'domains', but still get errors because they're on Next.js 14 which requires 'remotePatterns' with specific protocol and hostname objects. They try adding wildcards incorrectly. After checking the exact structure in the docs, they add \{ protocol: 'https', hostname: 'cdn.example.com', pathname: '/\*\*' \} to remotePatterns and the error resolves.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:38:46.555629+00:00— report_created — created