# Error: Invalid remotePatterns configuration in next.config.js. The 'hostname' field is required for each pattern.

- **ID:** `nextjs/invalid-image-remote-patterns`
- **Domain:** nextjs
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 93%

## Root Cause

The `images.remotePatterns` array in next.config.js contains an object without a `hostname` field, which is mandatory. Next.js requires each pattern to have at least a hostname to match remote image URLs.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Next.js 13.0.0 | active | — | — |
| Next.js 14.0.0 | active | — | — |
| Next.js 14.2.0 | active | — | — |

## Workarounds

1. **Ensure each object in remotePatterns has at least a hostname field. Example: `images: { remotePatterns: [{ hostname: 'example.com' }, { hostname: 'cdn.example.com', protocol: 'https' }] }`.** (95% success)
   ```
   Ensure each object in remotePatterns has at least a hostname field. Example: `images: { remotePatterns: [{ hostname: 'example.com' }, { hostname: 'cdn.example.com', protocol: 'https' }] }`.
   ```
2. **If allowing all hosts, use a wildcard hostname: `images: { remotePatterns: [{ hostname: '**' }] }`. Note: this is insecure for production; use specific hostnames instead.** (90% success)
   ```
   If allowing all hosts, use a wildcard hostname: `images: { remotePatterns: [{ hostname: '**' }] }`. Note: this is insecure for production; use specific hostnames instead.
   ```
3. **Use the deprecated `domains` array instead of remotePatterns for simple cases: `images: { domains: ['example.com'] }`. Note: domains is deprecated in Next.js 14 but still works.** (85% success)
   ```
   Use the deprecated `domains` array instead of remotePatterns for simple cases: `images: { domains: ['example.com'] }`. Note: domains is deprecated in Next.js 14 but still works.
   ```

## Dead Ends

- **** — The hostname field is still required even if protocol is specified; Next.js will still throw the same error. (100% fail)
- **** — While a wildcard hostname is allowed, it must still be explicitly provided as a string; omitting the hostname field entirely will still cause the error. (90% fail)
- **** — An empty array will not match any remote images, causing a different error: 'Invalid src prop on next/image, hostname is not configured' for any remote image. (80% fail)
