Next.js · Senior · Question 63 of 75
Why is images.domains deprecated in favor of images.remotePatterns?
- ✓Correct answer: Patterns can restrict protocol, port and path, so the optimizer can't be abused to fetch arbitrary files from a host
- 2
domainsis slower to match - 3
remotePatternsenables AVIF
Explanation
A whole domain is often too broad, e.g. a CDN host serving user uploads. Narrow patterns reduce the image optimizer's attack surface.