Skip to main content
IncomingMessage.prototype.url - node__http.d.ts - Node documentation
property IncomingMessage.prototype.url

Usage in Deno

```typescript import { IncomingMessage } from "node:node__http.d.ts"; ```
**Only valid for request obtained from [Server](../.././node__http.d.ts/~/Server).** Request URL string. This contains only the URL that is present in the actual HTTP request. Take the following request: ```http GET /status?name=ryan HTTP/1.1 Accept: text/plain ``` To parse the URL into its parts: ```js new URL(`http://${process.env.HOST ?? 'localhost'}${request.url}`); ``` When `request.url` is `'/status?name=ryan'` and `process.env.HOST` is undefined: ```console $ node > new URL(`http://${process.env.HOST ?? 'localhost'}${request.url}`); URL { href: 'http://localhost/status?name=ryan', origin: 'http://localhost', protocol: 'http:', username: '', password: '', host: 'localhost', hostname: 'localhost', port: '', pathname: '/status', search: '?name=ryan', searchParams: URLSearchParams { 'name' => 'ryan' }, hash: '' } ``` Ensure that you set `process.env.HOST` to the server's host name, or consider replacing this part entirely. If using `req.headers.host`, ensure proper validation is used, as clients may specify a custom `Host` header.

Type

string | undefined