/axios-behind-proxy

Wrapper for axios library, which provides ability to run behind proxy based on environment configuration http_proxy, https_proxy, no_proxy.

Primary LanguageTypeScript

Code in this GIT repository wraps axios to add a proxy support.

This code respects and uses environment variables:

  • http_proxy
  • https_proxy
  • no_proxy

Supported also HTTPS connections over HTTP proxy and vice versa. For example, if you uses HTTPS connections over HTTP proxy, expected configuration format is:

https_proxy="http://you-proxy:port"

For proxy connection it is used a tunnelled proxy (command CONNECT). Used library tunnel.

Usage

import axiosBehindProxy from './index';

const apiResponse = await axiosBehindProxy(/* parameters same as Axios */);

// Whole behavior is same as axios

Note

This project and code is just example. Check and improve it before going to production. :-)