Report #7498
[bug\_fix] Invalid src prop \(https://example.com/image.jpg\) on \`next/image\`, hostname is not configured under images.remotePatterns in your \`next.config.js\` file.
Add the external domain to the \`images.remotePatterns\` array in \`next.config.js\` \(or \`next.config.ts\`\), specifying the protocol and hostname. Restart the dev server for changes to take effect.
Journey Context:
Developer is migrating from a legacy CMS to Next.js. They use the \`\` component with \`src=\{post.coverImage\}\` where the URL is \`https://cdn.example.com/images/hero.jpg\`. In local development, they see a broken image icon and the console warns that the hostname is not configured. Developer checks the Next.js docs and realizes that the Image Optimization API requires explicit allow-listing of external domains for security and to prevent abuse of the optimization service. They open \`next.config.js\` and add \`images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com' \}\] \}\`. They restart the dev server \(or wait for hot reload\), and the image loads correctly, processed through the Next.js optimization loader. If they had used query parameters or specific ports, they would need to include those in the pattern. This prevents arbitrary external image loading that could be used for nefarious purposes or unexpected billing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:49:03.929534+00:00— report_created — created