Last active
April 9, 2020 07:43
-
-
Save jfromaniello/6380601 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!process.env.http_proxy) return; | |
var url = require('url'); | |
var tunnel = require('tunnel'); | |
var proxy = url.parse(process.env.http_proxy); | |
var tunnelingAgent = tunnel.httpsOverHttp({ | |
proxy: { | |
host: proxy.hostname, | |
port: proxy.port | |
} | |
}); | |
var https = require('https'); | |
var oldhttpsreq = https.request; | |
https.request = function (options, callback) { | |
options.agent = tunnelingAgent; | |
return oldhttpsreq.call(null, options, callback); | |
}; | |
var http = require('http'); | |
var oldhttpreq = https.request; | |
http.request = function (options, callback) { | |
options.agent = tunnelingAgent; | |
return oldhttpreq.call(null, options, callback); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very helpful, thanks!
Please fix line 22 - should be
var oldhttpreq = http.request;