Report #25484
[bug\_fix] Error: Invalid src prop on \`next/image\`, hostname "example.com" is not configured under images.remotePatterns in next.config.js
Configure the external hostname in \`next.config.js\` under the \`images.remotePatterns\` array, specifying protocol, hostname, and optional port/pathname for security.
Journey Context:
Developer uses the \`next/image\` component with an external URL: \`\`. In development or production, the image fails to load and the console shows an error stating the hostname is not configured. Developer checks the URL for typos, then searches the Next.js docs. They learn that Next.js Image Optimization API restricts which external hosts can be used to prevent malicious URLs and bandwidth abuse. Initially, they find old blog posts mentioning \`images.domains\` array \(legacy\). In Next.js 13\+, the configuration moved to \`images.remotePatterns\` which supports wildcard subdomains and pathname glob patterns for finer security control. Developer updates \`next.config.js\` to include: \`images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com', pathname: '/photos/\*\*' \}\] \}\`. They restart the dev server \(config changes require restart\). 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-17T21:10:46.211017+00:00— report_created — created