Common Next.js errorsnext/image: hostname is not configured under images
Invalid src prop (https://cdn.example.com/a.jpg) on `next/image`, hostname "cdn.example.com" is not configured under images in your `next.config.js`. Next.js only optimises images from hosts you've listed, so nobody can use your site to resize images from anywhere.
Why it happens in production
Often the images started coming from somewhere new: a CMS moved its CDN, uploads went to a different bucket, or a user added an image hosted elsewhere.
How to fix it
import type { NextConfig } from 'next'
const config: NextConfig = {
images: {
remotePatterns: [
{ protocol: 'https', hostname: 'cdn.example.com', pathname: '/uploads/**' },
],
},
}
export default config
Keep the pattern as narrow as you can (a path, not the whole host), and use remotePatterns rather than the older domains setting. If images can come from anywhere, such as user-supplied links, render those with a plain <img> instead.