From ab5c3e5c819ca993e0616d178bc1d282af539508 Mon Sep 17 00:00:00 2001 From: ashubham Date: Thu, 12 Mar 2015 13:15:06 -0700 Subject: [PATCH] auth header added --- lib/http-proxy.js | 1 + lib/http-proxy/common.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/http-proxy.js b/lib/http-proxy.js index b1ad646f4..8d37dd212 100644 --- a/lib/http-proxy.js +++ b/lib/http-proxy.js @@ -41,6 +41,7 @@ module.exports.createProxyServer = * prependPath: * localAddress : * changeOrigin: + * auth : Basic authentication i.e. 'user:password' to compute an Authorization header. * hostRewrite: rewrites the location hostname on (301/302/307/308) redirects, Default: null. * } * diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 66e80f9a1..a8722f294 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -46,6 +46,10 @@ common.setupOutgoing = function(outgoing, options, req, forward) { extend(outgoing.headers, options.headers); } + if(options.auth){ + outgoing.auth = options.auth; + } + if (isSSL.test(options[forward || 'target'].protocol)) { outgoing.rejectUnauthorized = (typeof options.secure === "undefined") ? true : options.secure; }