You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

  1. # forwarded
  2. [![NPM Version][npm-image]][npm-url]
  3. [![NPM Downloads][downloads-image]][downloads-url]
  4. [![Node.js Version][node-version-image]][node-version-url]
  5. [![Build Status][ci-image]][ci-url]
  6. [![Test Coverage][coveralls-image]][coveralls-url]
  7. Parse HTTP X-Forwarded-For header
  8. ## Installation
  9. This is a [Node.js](https://nodejs.org/en/) module available through the
  10. [npm registry](https://www.npmjs.com/). Installation is done using the
  11. [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
  12. ```sh
  13. $ npm install forwarded
  14. ```
  15. ## API
  16. ```js
  17. var forwarded = require('forwarded')
  18. ```
  19. ### forwarded(req)
  20. ```js
  21. var addresses = forwarded(req)
  22. ```
  23. Parse the `X-Forwarded-For` header from the request. Returns an array
  24. of the addresses, including the socket address for the `req`, in reverse
  25. order (i.e. index `0` is the socket address and the last index is the
  26. furthest address, typically the end-user).
  27. ## Testing
  28. ```sh
  29. $ npm test
  30. ```
  31. ## License
  32. [MIT](LICENSE)
  33. [ci-image]: https://badgen.net/github/checks/jshttp/forwarded/master?label=ci
  34. [ci-url]: https://github.com/jshttp/forwarded/actions?query=workflow%3Aci
  35. [npm-image]: https://img.shields.io/npm/v/forwarded.svg
  36. [npm-url]: https://npmjs.org/package/forwarded
  37. [node-version-image]: https://img.shields.io/node/v/forwarded.svg
  38. [node-version-url]: https://nodejs.org/en/download/
  39. [coveralls-image]: https://img.shields.io/coveralls/jshttp/forwarded/master.svg
  40. [coveralls-url]: https://coveralls.io/r/jshttp/forwarded?branch=master
  41. [downloads-image]: https://img.shields.io/npm/dm/forwarded.svg
  42. [downloads-url]: https://npmjs.org/package/forwarded