mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-21 07:29:37 +01:00
up-storage: don't send X-Forwarded-For for proxies
It's not that important a feature to have, and it could break some proxies. ref https://github.com/rlidwka/sinopia/issues/254
This commit is contained in:
parent
7c822d06f6
commit
0d266be965
@ -361,12 +361,20 @@ Storage.prototype.search = function(startkey, options) {
|
|||||||
|
|
||||||
Storage.prototype._add_proxy_headers = function(req, headers) {
|
Storage.prototype._add_proxy_headers = function(req, headers) {
|
||||||
if (req) {
|
if (req) {
|
||||||
|
// Only submit X-Forwarded-For field if we don't have a proxy selected
|
||||||
|
// in the config file.
|
||||||
|
//
|
||||||
|
// Otherwise misconfigured proxy could return 407:
|
||||||
|
// https://github.com/rlidwka/sinopia/issues/254
|
||||||
|
//
|
||||||
|
if (!this.proxy) {
|
||||||
headers['X-Forwarded-For'] = (
|
headers['X-Forwarded-For'] = (
|
||||||
req && req.headers['x-forwarded-for']
|
req && req.headers['x-forwarded-for']
|
||||||
? req.headers['x-forwarded-for'] + ', '
|
? req.headers['x-forwarded-for'] + ', '
|
||||||
: ''
|
: ''
|
||||||
) + req.connection.remoteAddress
|
) + req.connection.remoteAddress
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// always attach Via header to avoid loops, even if we're not proxying
|
// always attach Via header to avoid loops, even if we're not proxying
|
||||||
headers['Via'] =
|
headers['Via'] =
|
||||||
|
Loading…
Reference in New Issue
Block a user