Report #11265
[bug\_fix] Error: Invalid src prop ... hostname is not configured under images.remotePatterns in next.config.js when using next/image with external URLs.
Add the external domain to the \`images.remotePatterns\` configuration in \`next.config.js\` \(or \`next.config.ts\`\), specifying the protocol and hostname \(and port if non-standard\), then restart the development server.
Journey Context:
Developer is migrating a blog from a CMS \(e.g., Contentful or Sanity\) to Next.js. They use the \`\` component from \`next/image\` with \`src=\{post.coverImage.url\}\`. The URL points to \`https://cdn.sanity.io/...\`. In development, they see an error overlay: "Error: Invalid src prop... hostname is not configured". The build also fails. Developer initially considers using a standard \`\` tag, losing optimization benefits. They search the error message and find the Next.js Image Optimization docs. They open \`next.config.js\` and add \`images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.sanity.io' \}\] \}\`. They restart the Next.js dev server \(necessary for config changes\). The error resolves and images load with optimization.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:52:18.722462+00:00— report_created — created