Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/content/api/5x/api/request/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Request Object
description: The request object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on
description: The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on
---

import Alert from '@components/primitives/Alert/Alert.astro';
Expand Down Expand Up @@ -234,13 +234,13 @@ console.dir(req.fresh);
// => true
```

### req.host
### req.hostname

<Signature type="String" />

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

When the [`trust proxy` setting](/api/application/#application-settings)
When the [`trust proxy` setting](/api/application/#options-for-trust-proxy-setting)
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.
Expand All @@ -251,21 +251,17 @@ 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'
console.dir(req.hostname);
// => 'example.com'
```

### req.hostname
### req.host

<Signature type="String" />

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

When the [`trust proxy` setting](/api/application/#options-for-trust-proxy-setting)
When the [`trust proxy` setting](/api/application/#application-settings)
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.
Expand All @@ -276,8 +272,12 @@ comma-separated values, in which the first value is used.

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

// Host: "[::1]:3000"
console.dir(req.host);
// => '[::1]:3000'
```

### req.ip
Expand Down
4 changes: 2 additions & 2 deletions src/content/api/5x/api/response/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Response
description: The response object represents the HTTP response that an Express app sends when it gets an HTTP request.
description: The res object represents the HTTP response that an Express app sends when it gets an HTTP request.
---

import Alert from '@components/primitives/Alert/Alert.astro';
Expand Down Expand Up @@ -1104,7 +1104,7 @@ res.type('.html'); // => 'text/html'
res.type('html'); // => 'text/html'
res.type('json'); // => 'application/json'
res.type('application/json'); // => 'application/json'
res.type('png'); // => image/png:
res.type('png'); // => 'image/png'
```

Aliased as `res.contentType(type)`.
Expand Down
Loading