# 错误：`next/image` 的 src 属性无效，远程图像不支持相对路径

- **ID:** `nextjs/next-image-src-relative-path`
- **领域:** nextjs
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

next/image 组件要求远程图像使用绝对 URL。提供相对路径（例如 '/images/photo.jpg'）而没有配置 remotePatterns 或 loader 会导致此错误，因为 Next.js 无法解析优化所需的基 URL。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| next@13.5.0 | active | — | — |
| next@14.0.0 | active | — | — |
| next@15.0.0 | active | — | — |

## 解决方案

1. ```
   通过环境变量或请求主机构造绝对 URL。
   ```
2. ```
   在 next.config.js 中配置 remotePatterns，并使用匹配模式的相对路径。
   ```

## 无效尝试

- **** — This still resolves to a relative path on the server, not an absolute URL; the error persists. (80% 失败率)
- **** — This disables optimization but doesn't fix the path resolution; the error still occurs. (90% 失败率)
