diff --git a/src/content/api/5x/api/request/index.mdx b/src/content/api/5x/api/request/index.mdx index 0340d3cd95..6cdc8db28b 100644 --- a/src/content/api/5x/api/request/index.mdx +++ b/src/content/api/5x/api/request/index.mdx @@ -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'; @@ -234,13 +234,13 @@ console.dir(req.fresh); // => true ``` -### req.host +### req.hostname -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. @@ -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 -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. @@ -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 diff --git a/src/content/api/5x/api/response/index.mdx b/src/content/api/5x/api/response/index.mdx index 52b3d287f4..03fffe9c07 100644 --- a/src/content/api/5x/api/response/index.mdx +++ b/src/content/api/5x/api/response/index.mdx @@ -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'; @@ -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)`.