Skip to content

Commit

Permalink
Add req.host property documentation to 5.x API
Browse files Browse the repository at this point in the history
  • Loading branch information
gireeshpunathil authored and dougwilson committed Apr 22, 2020
1 parent d13082d commit e39992d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _includes/api/en/5x/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
</li>
<li><a href="#req.fresh">req.fresh</a>
</li>
<li><a href="#req.host">req.host</a>
</li>
<li><a href="#req.hostname">req.hostname</a>
</li>
<li><a href="#req.ip">req.ip</a>
Expand Down
22 changes: 22 additions & 0 deletions _includes/api/en/5x/req-host.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<h3 id='req.host'>req.host</h3>

Contains the host derived from the `Host` HTTP header.

When the [`trust proxy` setting](api.html#app.settings.table)
does not evaluate to `false`, this property will instead get the value
from the `X-Forwarded-Host` header field. This header can be set by
the client or by the proxy.

If there is more than one `X-Forwarded-Host` header in the request, the
value of the first header is used. This includes a single header with
comma-separated values, in which the first value is used.

```js
// Host: "example.com:3000"
console.dir(req.host)
// => 'example.com:3000'

// Host: "[::1]:3000"
console.dir(req.host)
// => '[::1]:3000'
```
4 changes: 4 additions & 0 deletions _includes/api/en/5x/req.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ or [pez](https://www.npmjs.com/package/pez).
{% include api/en/5x/req-fresh.md %}
</section>

<section markdown="1">
{% include api/en/5x/req-host.md %}
</section>

<section markdown="1">
{% include api/en/5x/req-hostname.md %}
</section>
Expand Down

0 comments on commit e39992d

Please sign in to comment.