Skip to content

Add ENV http_proxy support #195

@gajus

Description

@gajus

Basically, every time I use this package, the first thing that I need to do is to write an abstraction that enables use of HTTP_PROXY env variable.

Something like this:

import fetch from 'node-fetch';
import HttpsProxyAgent from 'https-proxy-agent';

export default (url: string, options: Object = {}) => {
  const instanceOptions = {
    ...options
  };

  if (!options.agent && process.env.HTTP_PROXY) {
    instanceOptions.agent = new HttpsProxyAgent(process.env.HTTP_PROXY);
  }

  return fetch(url, instanceOptions);
};

I'd like this package to support it out of the box.

Using HTTP_PROXY and HTTPS_PROXY variables to configure proxy setting of an application is a well establish convention, https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=http_proxy%20environment%20variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions