Report #26699
[bug\_fix] Image with src '...' is missing required 'width' and 'height' attributes / The src attribute ... is not configured under images.remotePatterns
For local images, import the image file to automatically determine width/height. For remote images \(external URLs\), provide explicit width and height props, and configure the external domain in next.config.js under images.remotePatterns \(or legacy domains array\) to allow Next.js to optimize them.
Journey Context:
Developer switches from a standard tag to Next.js for performance. They write: . Immediately, they get a compile-time error: 'width and height are required'. They add width=\{800\} height=\{600\} manually. Now they get a runtime error or a 400 bad request from the Next.js image optimization API: 'The source URL is not allowed'. They check the docs and realize Next.js requires whitelisting external domains for security. They edit next.config.js to add images: \{ remotePatterns: \[\{ protocol: 'https', hostname: 'cdn.example.com' \}\] \}. The error persists because they forgot to restart the dev server. After restart, it works. For local images, they later learn that using import photo from './photo.jpg' automatically provides width/height, eliminating manual measurement. The root cause is that Next.js Image component requires dimensions to prevent layout shift \(CLS\) and requires domain whitelisting to prevent abuse of the image optimization service.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:13:02.328195+00:00— report_created — created