Skip to content

Commit ab5c3e5

Browse files
committed
auth header added
1 parent 245d73a commit ab5c3e5

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/http-proxy.js

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module.exports.createProxyServer =
4141
* prependPath: <true/false, Default: true - specify whether you want to prepend the target's path to the proxy path>
4242
* localAddress : <Local interface string to bind for outgoing connections>
4343
* changeOrigin: <true/false, Default: false - changes the origin of the host header to the target URL>
44+
* auth : Basic authentication i.e. 'user:password' to compute an Authorization header.
4445
* hostRewrite: rewrites the location hostname on (301/302/307/308) redirects, Default: null.
4546
* }
4647
*

lib/http-proxy/common.js

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
4646
extend(outgoing.headers, options.headers);
4747
}
4848

49+
if(options.auth){
50+
outgoing.auth = options.auth;
51+
}
52+
4953
if (isSSL.test(options[forward || 'target'].protocol)) {
5054
outgoing.rejectUnauthorized = (typeof options.secure === "undefined") ? true : options.secure;
5155
}

0 commit comments

Comments
 (0)