{"_id":"@fastify/proxy-addr","_rev":"4091672","name":"@fastify/proxy-addr","description":"Determine the address of a proxied request","dist-tags":{"latest":"5.1.0","next":"5.0.0"},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""}],"time":{"modified":"2025-12-02T22:23:08.000Z","created":"2021-02-12T18:16:02.939Z","5.1.0":"2025-09-28T15:18:44.994Z","5.0.0":"2024-09-04T08:07:26.856Z","5.0.0-pre.fv5.1":"2024-06-19T19:45:36.112Z","4.1.0":"2022-12-15T12:24:40.640Z","4.0.0":"2022-05-25T09:11:28.877Z","3.0.0":"2021-02-12T18:16:02.939Z"},"users":{},"author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"repository":{"type":"git","url":"git+https://github.com/fastify/proxy-addr.git"},"versions":{"5.1.0":{"name":"@fastify/proxy-addr","description":"Determine the address of a proxied request","version":"5.1.0","main":"index.js","type":"commonjs","types":"types/index.d.ts","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},{"name":"James Sumners","url":"https://james.sumners.info"},{"name":"Frazer Smith","email":"frazer.dev@icloud.com","url":"https://github.com/fdawgs"}],"license":"MIT","keywords":["ip","proxy","x-forwarded-for"],"repository":{"type":"git","url":"git+https://github.com/fastify/proxy-addr.git"},"bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"homepage":"https://github.com/fastify/proxy-addr#readme","funding":[{"type":"github","url":"https://github.com/sponsors/fastify"},{"type":"opencollective","url":"https://opencollective.com/fastify"}],"dependencies":{"@fastify/forwarded":"^3.0.0","ipaddr.js":"^2.1.0"},"devDependencies":{"@types/node":"^24.0.8","beautify-benchmark":"0.2.4","benchmark":"2.1.4","c8":"^10.1.2","eslint":"^9.17.0","neostandard":"^0.12.0","tsd":"^0.32.0"},"scripts":{"bench":"node benchmark/index.js","lint":"eslint","lint:fix":"eslint --fix","test":"npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"c8 --100 node --test"},"_id":"@fastify/proxy-addr@5.1.0","gitHead":"918e32cf3a7502c32d5a8426e42616c74fa34d67","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"shasum":"f5360b5dd83c7de3d41b415be4aab84ae44aa106","size":8534,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-5.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/proxy-addr/download/@fastify/proxy-addr-5.1.0.tgz"},"_npmUser":{"name":"eomm","email":"behemoth89@gmail.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/proxy-addr_5.1.0_1759072635900_0.06533958968416509"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-28T15:18:44.994Z","publish_time":1759072724994,"_source_registry_name":"default","_cnpm_publish_time":1759072724994},"5.0.0":{"name":"@fastify/proxy-addr","version":"5.0.0","keywords":["ip","proxy","x-forwarded-for"],"author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","_id":"@fastify/proxy-addr@5.0.0","maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""}],"homepage":"https://github.com/fastify/proxy-addr#readme","bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"dist":{"shasum":"e9d1c7a49b8380d9f92a879fdc623ac47ee27de3","size":8280,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/proxy-addr/download/@fastify/proxy-addr-5.0.0.tgz"},"main":"index.js","type":"commonjs","types":"types/index.d.ts","gitHead":"5602b6f4c043e0e6dbb815da77f72819763c9fd2","scripts":{"lint":"standard","test":"npm run test:unit && npm run test:typescript","bench":"node benchmark/index.js","lint:fix":"standard --fix","test:unit":"c8 tape test/**/*.js","test:typescript":"tsd"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"repository":{"url":"git+https://github.com/fastify/proxy-addr.git","type":"git"},"_npmVersion":"10.8.1","description":"Determine address of proxied request","directories":{},"_nodeVersion":"20.16.0","dependencies":{"ipaddr.js":"^2.1.0","@fastify/forwarded":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"c8":"^7.14.0","tsd":"^0.31.0","tape":"^5.7.5","standard":"^17.1.0","benchmark":"2.1.4","@types/node":"^22.0.0","beautify-benchmark":"0.2.4","@fastify/pre-commit":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/proxy-addr_5.0.0_1725437246620_0.3418155684548261","host":"s3://npm-registry-packages"},"_cnpmcore_publish_time":"2024-09-04T08:07:26.856Z","publish_time":1725437246856,"_source_registry_name":"default","_cnpm_publish_time":1725437246856},"5.0.0-pre.fv5.1":{"name":"@fastify/proxy-addr","description":"Determine address of proxied request","version":"5.0.0-pre.fv5.1","main":"index.js","type":"commonjs","types":"types/index.d.ts","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["ip","proxy","x-forwarded-for"],"repository":{"type":"git","url":"git+https://github.com/fastify/proxy-addr.git"},"bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"homepage":"https://github.com/fastify/proxy-addr#readme","dependencies":{"@fastify/forwarded":"^2.2.0","ipaddr.js":"^2.1.0"},"devDependencies":{"@fastify/pre-commit":"^2.1.0","@types/node":"^20.12.7","beautify-benchmark":"0.2.4","benchmark":"2.1.4","c8":"^7.14.0","standard":"^17.1.0","tape":"^5.7.5","tsd":"^0.31.0"},"scripts":{"bench":"node benchmark/index.js","lint":"standard","lint:fix":"standard --fix","test":"npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"c8 tape test/**/*.js"},"_id":"@fastify/proxy-addr@5.0.0-pre.fv5.1","readmeFilename":"README.md","gitHead":"e6cf439378027059e18ba1e3bb525f7f5ed31fea","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"shasum":"730274ba7dea1e6bd18f17bbcefd4db41823ed19","size":8294,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-5.0.0-pre.fv5.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/proxy-addr/download/@fastify/proxy-addr-5.0.0-pre.fv5.1.tgz"},"_npmUser":{"name":"jsumners","email":"james.sumners@gmail.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/proxy-addr_5.0.0-pre.fv5.1_1718826335932_0.8089826996114657"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-06-19T19:45:36.112Z","publish_time":1718826336112,"_source_registry_name":"default","_cnpm_publish_time":1718826336112},"4.1.0":{"name":"@fastify/proxy-addr","description":"Determine address of proxied request","version":"4.1.0","main":"index.js","types":"types/index.d.ts","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["ip","proxy","x-forwarded-for"],"repository":{"type":"git","url":"git+https://github.com/fastify/proxy-addr.git"},"bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"homepage":"https://github.com/fastify/proxy-addr#readme","dependencies":{"@fastify/forwarded":"^2.0.0","ipaddr.js":"^2.0.0"},"devDependencies":{"@types/node":"^18.11.11","beautify-benchmark":"0.2.4","benchmark":"2.1.4","standard":"^17.0.0","tap":"^16.0.0","tsd":"^0.25.0"},"scripts":{"bench":"node benchmark/index.js","lint":"standard","test":"npm run test:unit && npm run test:typescript","test:typescript":"tsd","test:unit":"tap"},"gitHead":"db635d606fb368a9d6e4736508fd5cf509c7a332","_id":"@fastify/proxy-addr@4.1.0","_nodeVersion":"16.17.0","_npmVersion":"9.1.2","dist":{"shasum":"511b412693301d50f189e9985b0f01af81ad6730","size":8115,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/proxy-addr/download/@fastify/proxy-addr-4.1.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/proxy-addr_4.1.0_1671107080372_0.9244830690855266"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-12-15T12:50:59.880Z","publish_time":1671107080640,"_cnpm_publish_time":1671107080640},"4.0.0":{"name":"@fastify/proxy-addr","description":"Determine address of proxied request","version":"4.0.0","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["ip","proxy","x-forwarded-for"],"repository":{"type":"git","url":"git+https://github.com/fastify/proxy-addr.git"},"bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"homepage":"https://github.com/fastify/proxy-addr#readme","dependencies":{"@fastify/forwarded":"^2.0.0","ipaddr.js":"^2.0.0"},"devDependencies":{"beautify-benchmark":"0.2.4","benchmark":"2.1.4","standard":"^17.0.0","tap":"^16.0.0"},"scripts":{"bench":"node benchmark/index.js","test":"standard && tap"},"gitHead":"c846304b73239e4aaef95b29c08f43c071e9bd05","_id":"@fastify/proxy-addr@4.0.0","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"shasum":"478938c185835e2e98a4ccdb06e1ba3c957e89b8","size":4330,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/proxy-addr/download/@fastify/proxy-addr-4.0.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/proxy-addr_4.0.0_1653469888726_0.58643301527822"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-25T10:37:14.949Z","publish_time":1653469888877,"_cnpm_publish_time":1653469888877},"3.0.0":{"name":"@fastify/proxy-addr","description":"Determine address of proxied request","version":"3.0.0","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["ip","proxy","x-forwarded-for"],"repository":{"type":"git","url":"git+https://github.com/fastify/proxy-addr.git"},"dependencies":{"@fastify/forwarded":"^1.0.0","ipaddr.js":"^2.0.0"},"devDependencies":{"beautify-benchmark":"0.2.4","benchmark":"2.1.4","standard":"^16.0.3","tap":"^14.11.0"},"scripts":{"bench":"node benchmark/index.js","test":"standard && tap"},"gitHead":"1ca1ae3cd8cb6f18b4b6fec8194ec5600e7ad7e8","bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"homepage":"https://github.com/fastify/proxy-addr#readme","_id":"@fastify/proxy-addr@3.0.0","_nodeVersion":"14.15.4","_npmVersion":"6.14.11","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"7d3bb6474a01b206010329291f4edf6af8af582d","size":4172,"noattachment":false,"key":"/@fastify/proxy-addr/-/@fastify/proxy-addr-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/proxy-addr/download/@fastify/proxy-addr-3.0.0.tgz"},"directories":{},"maintainers":[{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/proxy-addr_3.0.0_1613153762784_0.6577085370964424"},"_hasShrinkwrap":false,"publish_time":1613153762939,"_cnpm_publish_time":1613153762939}},"readme":"# proxy-addr\n\n[![CI](https://github.com/fastify/proxy-addr/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/proxy-addr/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/proxy-addr.svg?style=flat)](https://www.npmjs.com/package/@fastify/proxy-addr)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nDetermine the address of a proxied request.\n\nForked from https://github.com/jshttp/proxy-addr to address https://github.com/jshttp/forwarded/pull/9.\n\n## Install\n\n```sh\n$ npm i @fastify/proxy-addr\n```\n\n## API\n\n<!-- eslint-disable no-unused-vars -->\n\n```js\nconst proxyaddr = require('@fastify/proxy-addr')\n```\n\n### proxyaddr(req, trust)\n\nReturn the address of the request, using the given `trust` parameter.\n\nThe `trust` argument is a function that returns `true` if you trust\nthe address, `false` if you don't. The closest untrusted address is\nreturned.\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr(req, function (addr) { return addr === '127.0.0.1' })\nproxyaddr(req, function (addr, i) { return i < 1 })\n```\n\nThe `trust` argument may also be a single IP address string or an\narray of trusted addresses, as plain IP addresses, CIDR-formatted\nstrings, or IP/netmask strings.\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr(req, '127.0.0.1')\nproxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8'])\nproxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0'])\n```\n\nThis module also supports IPv6. Your IPv6 addresses will be normalized\nautomatically (i.e. `fe80::00ed:1` equals `fe80:0:0:0:0:0:ed:1`).\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr(req, '::1')\nproxyaddr(req, ['::1/128', 'fe80::/10'])\n```\n\nThis module will automatically work with IPv4-mapped IPv6 addresses\nas well to support node.js in IPv6-only mode. This means that you do\nnot have to specify both `::ffff:a00:1` and `10.0.0.1`.\n\nAs a convenience, this module also takes certain pre-defined names\nin addition to IP addresses, which expand into IP addresses:\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr(req, 'loopback')\nproxyaddr(req, ['loopback', 'fc00:ac:1ab5:fff::1/64'])\n```\n\n  * `loopback`: IPv4 and IPv6 loopback addresses (like `::1` and\n    `127.0.0.1`).\n  * `linklocal`: IPv4 and IPv6 link-local addresses (like\n    `fe80::1:1:1:1` and `169.254.0.1`).\n  * `uniquelocal`: IPv4 private addresses and IPv6 unique-local\n    addresses (like `fc00:ac:1ab5:fff::1` and `192.168.0.1`).\n\nWhen `trust` is specified as a function, it will be called for each\naddress to determine if it is a trusted address. The function is\ngiven two arguments: `addr` and `i`, where `addr` is a string of\nthe address to check and `i` is a number that represents the distance\nfrom the socket address.\n\n### proxyaddr.all(req, [trust])\n\nReturn all the request addresses, optionally stopping at the\nfirst untrusted. This array is ordered from closest to furthest\n(i.e. `arr[0] === req.connection.remoteAddress`).\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr.all(req)\n```\n\nThe optional `trust` argument takes the same arguments as `trust`\ndoes in `proxyaddr(req, trust)`.\n\n<!-- eslint-disable no-undef -->\n\n```js\nproxyaddr.all(req, 'loopback')\n```\n\n### proxyaddr.compile(val)\n\nCompiles argument `val` into a `trust` function. This function takes\nthe same arguments as `trust` does in `proxyaddr(req, trust)` and\nreturns a function suitable for `proxyaddr(req, trust)`.\n\n<!-- eslint-disable no-undef, no-unused-vars -->\n\n```js\nconst trust = proxyaddr.compile('loopback')\nconst addr = proxyaddr(req, trust)\n```\n\nThis function is meant to be optimized for use against every request.\nIt is recommended that a trust function be compiled up-front for the\ntrusted configuration and passed to proxyaddr(req, trust) for each request.\n\n## Testing\n\n```sh\n$ npm test\n```\n\n## Benchmarks\n\n```sh\n$ npm run bench\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","_attachments":{},"homepage":"https://github.com/fastify/proxy-addr#readme","bugs":{"url":"https://github.com/fastify/proxy-addr/issues"},"license":"MIT"}