ChatGPTNextWeb / ChatGPTNextWeb/NextChat
[Bug] x-forwarded-host not match 错误
- Dominant language
- TypeScript
- Stars
- 88.8k
- Forks
- 59.1k
- PR merge metrics
- No merged PRs in 30d
Description
### 📦 部署方式
Docker
### 📌 软件版本
v2.16.0
### 💻 系统环境
Ubuntu
### 📌 系统版本
24.04.1 LTS
### 🌐 浏览器
Firefox
### 📌 浏览器版本
139.0.4 (64 位)
### 🐛 问题描述
docker部署,通过nginx反代后前端报下面的错误:

当然聊天也不行,直接显示....

后台查日志好像有下面的错误:
```
app-1 | `x-forwarded-host` header with value `127.0.0.1:3002` does not match `origin` header with value `这个地方是我的域名` from a forwarded Server Actions request. Aborting the action.
app-1 | Error: Invalid Server Actions request.
app-1 | at rm (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:5881)
app-1 | at rq (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:1255)
app-1 | at /app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:3935
app-1 | at AsyncLocalStorage.run (node:async_hooks:338:14)
app-1 | at Object.wrap (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:13:16239)
app-1 | at /app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:3825
app-1 | at AsyncLocalStorage.run (node:async_hooks:338:14)
app-1 | at Object.wrap (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:13:15487)
app-1 | at rW (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:3752)
app-1 | at no.render (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:7725)
```
nginx非常简单就是下面(一直用的这个没有问题的,至少v2.15.8是ok的):
```
proxy_buffering off;
location / {
proxy_pass http://127.0.0.1:3002;
}
```
### 📷 复现步骤
docker部署2.16.0版本,然后通过nginx反代
### 🚦 期望结果
能正常使用
### 📝 补充信息
2.15.8没有这个问题,而且其他配置都没有动过,搜索了下好像是Next.js有这个问题?但是我看了下代码又没有这个配置,难道要加上?
https://raddy.dev/blog/next-js-14-0-2-x-forwarded-host-header-with-value-localhost3000-does-not-match-origin-fix/
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Docker deployment and nginx proxy configuration described in the issue, then compare behavior between v2.15.8 and v2.16.0 while tracing the Next.js Server Actions request handling. Reproduce the x-forwarded-host and origin mismatch through the reverse proxy; done means the Docker deployment works normally behind nginx without the invalid Server Actions request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, next.js, nginx, typescript
- Domain
- backend, devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100