# current-url

> Get the current URL isomorphically.

Latest version **2.3.0** (published 2023-09-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install current-url
pnpm add current-url
yarn add current-url
bun add current-url
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2023-09-21 |
| First published | 2022-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alex Mendes |
| Maintainers | alexmendes |

## Links

- npm: https://www.npmjs.com/package/current-url
- Repository: https://github.com/alexandermendes/current-url
- Homepage: https://github.com/alexandermendes/current-url#readme
- Issues: https://github.com/alexandermendes/current-url/issues
- npm.io page: https://npm.io/package/current-url

## Dependencies (3)

- [typescript](https://npm.io/package/typescript.md) ^5.0.4
- [original-url](https://npm.io/package/original-url.md) ^1.2.3
- [get-request-origin](https://npm.io/package/get-request-origin.md) ^1.1.0

## Recent versions

- 2.3.0 (latest) — 2023-09-21
- 2.2.3 — 2023-09-21
- 2.2.2 — 2023-09-21
- 2.2.1 — 2023-09-21
- 2.2.0 — 2023-09-21
- 2.1.2 — 2022-05-24
- 2.1.1 — 2022-02-14
- 2.1.0 — 2022-02-14
- 2.0.3 — 2022-02-09
- 2.0.2 — 2022-02-08
- 2.0.1 — 2022-02-04
- 2.0.0 — 2022-02-04
- 1.0.0 — 2022-02-03

## README

# current-url

[![npm version](https://badge.fury.io/js/current-url.svg)](https://badge.fury.io/js/current-url)

Get the current URL isomorphically.

Respects the following HTTP headers:
- `Host`
- `Forwarded`
- `X-Forwarded-Proto`
- `X-Forwarded-Protocol`
- `X-Url-Scheme`
- `Front-End-Https`
- `X-Forwarded-Ssl`
- `X-Forwarded-Host`
- `X-Forwarded-Port`
- `X-Replaced-Path`

## Installation

```
yarn add current-url
```

## Usage

In the browser call the function with no arguments:

```js
import { currentUrl } from 'current-url';

currentUrl();
```

On the server call the function with a Node HTTP request object as the first argument:

```js
import { currentUrl } from 'current-url';

currentUrl(req);

// Ignore proxies
currentUrl(req, { ignoreProxies: true });
```

In both cases the function returns a `URL` object.

## Options

### `ignoreProxies`

Type: `object`\
Default: `false`

By default, the `currentUrl` function will take into account potential URL
rewrites made by proxies, load balancers, etc. along the way (as long as these
append special HTTP headers to the request). Use this option to disable that
behaviour.

---
_Source: https://npm.io/package/current-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
