https://github.com/unjs-archive/requrl
Grab full URL from request.
https://github.com/unjs-archive/requrl
http incomingmessage node req url
Last synced: 4 months ago
JSON representation
Grab full URL from request.
- Host: GitHub
- URL: https://github.com/unjs-archive/requrl
- Owner: unjs-archive
- Created: 2019-11-21T16:01:22.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-04-29T10:14:48.000Z (over 1 year ago)
- Last Synced: 2025-09-27T15:05:32.333Z (4 months ago)
- Topics: http, incomingmessage, node, req, url
- Language: TypeScript
- Homepage:
- Size: 332 KB
- Stars: 37
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# requrl
[](https://www.npmjs.com/package/requrl)
[](https://www.npmjs.com/package/requrl)
[](https://bundlephobia.com/result?p=requrl)
Grab full URL from [request](https://nodejs.org/api/http.html#http_class_http_incomingmessage).
## Features
- Universal (browser and node.js) support
- Detect HTTPS requests using [is-https](https://github.com/nuxt-contrib/is-https)
- Support `x-forwarded-proto` and `x-forwarded-host`
- Always encode URI
- Super Small
## Usage
```js
import getURL from 'requrl'
// OR
const getURL = require('requrl')
```
Function signuture is:
```ts
function getURL(req?: IncomingMessage, includePath?: boolean): string
```
Example:
```js
const url = getURL(req)
// http://localhost:3000
// https://www.foo.com
```
## License
MIT