Skip to content

Commit 37aabaa

Browse files
authored
chore: hostHeaders default value is empty string (#5412)
closes #5411
1 parent bf29d28 commit 37aabaa

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

site/docs/basics/controller.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,10 @@ Specially when we set `config.proxy = true` to deploy the application behind the
605605

606606
#### `ctx.host`
607607

608-
Reads the header's value configured by `config.hostHeaders` firstly, if fails, then it tries to get the value of host header, if fails again, it returns an empty string.
608+
Reads the header's value configured by `config.hostHeaders` firstly, if fails, then it tries to get the value of `host` header, if fails again, it returns an empty string.
609609

610-
`config.hostHeaders` defaults to `x-forwarded-host`.
610+
`config.hostHeaders` defaults to `''`.
611+
If the application is deployed behind a reverse proxy and `config.proxy = true` is configured, a correct value needs to be configured here, such as `x-forwarded-host`. Please configure it according to the actual value of the proxy.
611612

612613
#### `ctx.protocol`
613614

site/docs/basics/controller.zh-CN.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ module.exports = {
596596

597597
此 Getter 优先读取 `config.hostHeaders` 中配置的 header 值。若无法获取,则尝试读取 `host` 这个 header 的值。若仍旧获取不到,则返回空字符串。
598598

599-
`config.hostHeaders` 的默认配置为 `x-forwarded-host`
599+
`config.hostHeaders` 的默认配置为 `''` 空字符串。
600+
如果应用部署在反向代理后面,并且配置了 `config.proxy = true`,需要在这里配置一个正确的值,例如 `x-forwarded-host`,请按照代理真实值配置。
600601

601602
#### `ctx.protocol`
602603

@@ -1077,4 +1078,4 @@ exports.security = {
10771078
};
10781079
```
10791080

1080-
如果没有配置 `domainWhiteList``domainWhiteList` 数组为空,则默认允许所有跳转请求,等同于使用 `ctx.unsafeRedirect(url)`
1081+
如果没有配置 `domainWhiteList``domainWhiteList` 数组为空,则默认允许所有跳转请求,等同于使用 `ctx.unsafeRedirect(url)`

0 commit comments

Comments
 (0)