Override HTTP and HTTPS to set global proxy out settings

Usage no npm install needed!

<script type="module">
  import proxyOut from '';




To use, simply require at any point before making your outgoing HTTP or HTTPS requests (Generally at the top of your server JS):


Requiring proxy-out will override your http.request, http.get, https.request and https.get methods to route through your proxy. This is useful if you're working in a corporate space, behind a corporate proxy.


Sometimes, you'll want to route to internal destinations and won't want them running through a proxy (A proxy won't know how to get back to your localhost, for instance). In this situation, you can add a whitelist by supplying the hostnames as an array like so:

var whitelist = ['localhost', '', 'my-site.local'];
require('proxy-out')('', whitelist);


Testing actually attempts to connect to an external site (, so you'll need a working proxy. By default, test.js checks for the environment variable http_proxy.

export http_proxy=
npm test