MCPcopy
hub / github.com/tinyhttp/tinyhttp / forwarded

Function forwarded

packages/forwarded/src/index.ts:6–13  ·  view source on GitHub ↗
(req: Pick<IncomingMessage, 'headers' | 'connection'>)

Source from the content-addressed store, hash-verified

4 * Get all addresses in the request, using the `X-Forwarded-For` header.
5 */
6export function forwarded(req: Pick<IncomingMessage, 'headers' | 'connection'>) {
7 // simple header parsing
8 const proxyAddrs = parse((req.headers['x-forwarded-for'] as string) || '')
9 const socketAddr = req.connection.remoteAddress
10
11 // return all addresses
12 return [socketAddr].concat(proxyAddrs)
13}
14
15/**
16 * Parse the X-Forwarded-For header.

Callers 2

alladdrsFunction · 0.90
forwarded.test.tsFile · 0.90

Calls 1

parseFunction · 0.70

Tested by

no test coverage detected