Skip to content

Instantly share code, notes, and snippets.

@seeya
Created October 27, 2017 07:39
Show Gist options
  • Save seeya/de86c2486ae102f71700dfe7677ff18e to your computer and use it in GitHub Desktop.
Save seeya/de86c2486ae102f71700dfe7677ff18e to your computer and use it in GitHub Desktop.
PAC with nodejs request
// Using a PAC file with request nodejs
// https://blog.birkhoff.me/node-js-request-via-local-pac-file/
// npm install pac-proxy-agent
var request = require("request");
var pacURL = 'http://127.0.0.1:16823/proxy_on.pac';
var agent = new require('pac-proxy-agent')('pac+' + pacURL);
var reqURL = 'https://www.google.com.tw';
request({ url: reqURL, agent: agent }, function (error, response, body) {
// code..
});
@vanduc1102
Copy link

it works for me, thank man

@god-lin
Copy link

god-lin commented Dec 13, 2021

HTTPError: Bad Request
my response,i search everywhere, wher is my luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment