Skip to content

Commit ec80aaa

Browse files
authored
Merge pull request #40 from runk/auth
Authentication support
2 parents 92a89ce + 39cde1b commit ec80aaa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/proxy.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,17 @@ exports.httpHandler = function(req, res) {
8787
dest = schema + '://' + req.headers['host'] + path;
8888

8989
var params = {
90-
url: dest,
91-
rejectUnauthorized: false
90+
headers: {},
91+
rejectUnauthorized: false,
92+
url: dest
9293
};
9394

95+
// Carry following headers down to dest npm repository.
96+
var carryHeaders = ['authorization', 'version', 'referer', 'npm-session', 'user-agent'];
97+
carryHeaders.forEach(function(name) {
98+
params.headers[name] = req.headers[name];
99+
});
100+
94101
if (exports.opts.proxy)
95102
params.proxy = exports.opts.proxy;
96103

0 commit comments

Comments
 (0)