# @fastify/forwarded

> Parse HTTP X-Forwarded-For header

Latest version **3.0.2** (published 2026-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fastify/forwarded
pnpm add @fastify/forwarded
yarn add @fastify/forwarded
bun add @fastify/forwarded
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2026-07-28 |
| First published | 2021-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Douglas Christopher Wilson |
| Maintainers | delvedor, matteo.collina, jsumners, eomm, climba03003 |
| Keywords | x-forwarded-for, http, req |

## Links

- npm: https://www.npmjs.com/package/@fastify/forwarded
- Repository: https://github.com/fastify/forwarded
- Homepage: https://github.com/fastify/forwarded#readme
- Issues: https://github.com/fastify/forwarded/issues
- Funding: https://github.com/sponsors/fastify
- npm.io page: https://npm.io/package/@fastify/forwarded

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2026-07-28
- 3.0.1 — 2025-09-28
- 3.0.0 — 2024-07-13
- 2.2.0 — 2022-12-05
- 2.1.0 — 2022-07-07
- 2.0.0 — 2022-05-25
- 1.0.0 — 2021-02-12
- 0.1.2 — 2021-02-12

## README

# @fastify/forwarded

[![CI](https://github.com/fastify/forwarded/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/forwarded/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/@fastify/forwarded.svg?style=flat)](https://www.npmjs.com/package/@fastify/forwarded)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)

Parse HTTP X-Forwarded-For header.

Updated version of the great https://github.com/jshttp/forwarded.
Implements https://github.com/jshttp/forwarded/pull/9.

## Installation

```sh
$ npm i @fastify/forwarded
```

## API

```js
const forwarded = require('@fastify/forwarded')
```

### forwarded(req)

```js
const addresses = forwarded(req)
```

Parse the `X-Forwarded-For` header from the request. Returns an array
of the addresses, including the socket address for the `req`, in reverse
order (i.e. index `0` is the socket address and the last index is the
furthest address, typically the end-user).

## Testing

```sh
$ npm test
```

## License

[MIT](LICENSE)

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