Sha256: 72bbb8047c48c217040bfa42a9e76e43a1fb9d6b6edeced5c772a85a11cbd866
Contents?: true
Size: 641 Bytes
Versions: 15
Compression:
Stored size: 641 Bytes
Contents
/*! * forwarded * Copyright(c) 2014 Douglas Christopher Wilson * MIT Licensed */ /** * Module exports. */ module.exports = forwarded /** * Get all addresses in the request, using the `X-Forwarded-For` header. * * @param {Object} req * @api public */ function forwarded(req) { if (!req) { throw new TypeError('argument req is required') } // simple header parsing var proxyAddrs = (req.headers['x-forwarded-for'] || '') .split(/ *, */) .filter(Boolean) .reverse() var socketAddr = req.connection.remoteAddress var addrs = [socketAddr].concat(proxyAddrs) // return all addresses return addrs }
Version data entries
15 entries across 15 versions & 3 rubygems