List the allowed hosts in images.remotePatterns in next.config.js. The older images.domains option still works but is deprecated.
// next.config.js
module.exports = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "images.example.com",
pathname: "/uploads/**",
},
],
},
};Restart the dev server after changing the config. Patterns can match a path prefix, a port and wildcard subdomains, which lets you allow only what you need instead of a whole domain.
If the project uses a static export (output: "export"), the built-in image optimizer is not available, so set images.unoptimized to true.
