Forwarded HTTP
Resolves RFC 7239 (Forwarded HTTP Extension), with fallback to all legacy & special Forward headers: X-Forwarded-*
, X-Real-*
, Fastly-Client-IP
, X-Cluster-Client-IP
, and others.
Focuses on resolving to the RFC standard and providing a consistent access to HTTP Forwarded Parameters: by
, for
, host
, proto
.
Install
npm install --save forwarded-http
API
forwarded(http.IncomingMessage)
var forwarded = require('forwarded-http')
var params = forwarded(req)
assert(params.port === '8000')
assert(params.for === { '0.0.0.1': '8000', '0.0.0.2': '8001' })
assert(params.proto === 'https')
assert(params.host === 'foo.com')
assert(params.ports === ['8000', '8001'])
assert(params.ips === ['0.0.0.1', '0.0.0.2'])
Support
Donations are welcome to help support the continuous development of this project.
License
MIT © Ahmad Nassri