You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey,
So I've been trying to get proxyUrl to work with an external pac file but it doesn't seem to be working. Running the following script with the curl request shows the pac file is never fetched from the local server and mockttp fails to forward the request to the 2nd proxy with the log message, Failed to handle request: buildProxyAgent is not a function:
constmockttp=require("mockttp");// start local server to host a pac fileconstserver=require("http").createServer((req,res)=>{console.log("Request made to PAC file server");if(req.url==='/proxy.pac'){console.log("PAC file server response");res.writeHead(200,{'Content-Type': 'text/javascript'});res.write(` function FindProxyForURL(url, host) { if (shExpMatch(url, '*www.bbc.com*')) { return "PROXY localhost:8096; DIRECT"; } return "DIRECT"; }`);}res.end();});server.listen(5010,'localhost',()=>console.log("Started PAC file server on localhost:5010"));// Launch 2 proxies the first using a PAC file that redirects some requests to proxy 2(async()=>{consthttps=awaitmockttp.generateCACertificate();// Proxy 1constproxy1=mockttp.getLocal({debug: true,http2: false, https });awaitproxy1.start(8095);console.log('1st Proxy on 8095');awaitproxy1.forAnyRequest().thenPassThrough({beforeRequest: req=>{console.log('Reached the 1st Proxy:',req.url)returnreq;},ignoreHostHttpsErrors: true,proxyConfig: {proxyUrl: 'pac+http://localhost:5010/proxy.pac'}});// Proxy 2constproxy2=mockttp.getLocal({debug: true,http2: false, https });awaitproxy2.start(8096);console.log('bbc.com requests only proxy on 8096');awaitproxy2.forAnyRequest().thenPassThrough({beforeRequest: req=>{console.log('bbc.com request received:',req.url)returnreq;},ignoreHostHttpsErrors: true});})();
Curl Request: curl -k -x "http://127.0.0.1:8095/" "https://www.bbc.com/" -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
It looks like buildProxyAgent is an object containing a class rather than a function. This might be related to changes in pac-proxy-agent potentially?
The text was updated successfully, but these errors were encountered:
Hmm, yes that definitely seems broken, and it does look like somehow this doesn't have any existing tests either. Would you be interested in opening a PR? I expect the actual fix isn't too difficult (relevant code is here: https://github.com/httptoolkit/mockttp/blob/main/src/rules/http-agents.ts) and most of the test code we'll need is already in the example above.
Hey,
So I've been trying to get
proxyUrl
to work with an external pac file but it doesn't seem to be working. Running the following script with the curl request shows the pac file is never fetched from the local server and mockttp fails to forward the request to the 2nd proxy with the log message,Failed to handle request: buildProxyAgent is not a function
:Curl Request: curl -k -x "http://127.0.0.1:8095/" "https://www.bbc.com/" -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
It looks like
buildProxyAgent
is an object containing a class rather than a function. This might be related to changes in pac-proxy-agent potentially?The text was updated successfully, but these errors were encountered: