Git Product home page Git Product logo

praxios's Introduction

praxios

npm GitHub Workflow Status

A wrapper over the axios library to support corporate proxies well

Table of Contents

Installation

npm:

npm install praxios

yarn:

yarn add praxios

Usage

Proxy without authentication

//proxy.js
import praxios from "praxios";

proxios
 .get("/dummy")
 .then(response => {
  console.log(response.data);
 })
 .catch(error => {
  console.log(error);
 });
export PROXY_HOST="my-corporate-proxy.local"
export PROXY_PORT="3128"
node proxy.js

Proxy with authentication

export PROXY_HOST="my-corporate-proxy.local"
export PROXY_PORT="3128"
export PROXY_USERNAME="foo"
export PROXY_PASSWORD="bar"
node proxy.js

Bypass proxy for hosts

export PROXY_HOST="my-corporate-proxy.local"
export PROXY_PORT="3128"
export NO_PROXY="host1.domain,host2.domain,1.2.3.4"
node proxy.js

Customizing the axios settings or using without proxy

The library also exposes the built-in axios library for any advanced configuration or customization

//custom.js
import { baseAxios } from "praxios";

const axios = baseAxios.create({
 httpsAgent: {},
 baseUrl: "",
});

axios
 .get("/dummy")
 .then(response => {
  console.log(response.data);
 })
 .catch(error => {
  console.log(error);
 });

Resources

Credits

praxios was mostly inspired out of the great work and research done by Jan Molak documented very well on this blog post: Node.js Axios behind corporate proxies

License

MIT

praxios's People

Contributors

aneeshrelan avatar semantic-release-bot avatar jn-aman avatar

Watchers

Kapil Mohan avatar  avatar

Forkers

jn-aman vikki978

praxios's Issues

Add README

Is your feature request related to a problem? Please describe.
Add README docs for usage

Describe the solution you'd like
NA

Describe alternatives you've considered
NA

Additional context
NA

not handling empty string values for environment variables PROXY_HOST and PROXY_PORT

Describe the bug
PROXY_HOST and PROXY_PORT if they are initialized with an empty string, the proxy detection logic fails

To Reproduce
Steps to reproduce the behavior:

  1. Set the above vars to empty string and run

Expected behavior
Empty string should signify proxy not being configured

Screenshots
NA

Environment (please complete the following information):

  • Node Version: All
  • Package Version: 1.0.0
  • OS Version: All

Additional context
NA

Exception Invalid IP Addresses on passing a NO_PROXY string in the environment variables

Describe the bug
To bypass the proxy for a few set of hosts, linux leverages the NO_PROXY environment variable that is supported by axios as well. On setting this along with other proxy settings, the requests fail with an error of `Exception caught in : Invalid IP Address:

To Reproduce
Steps to reproduce the behavior:

  1. Set the NO_PROXY="host1,host1" and run any script using this library
  2. Crashes with error

Expected behavior
It should bypass proxy for the mentioned hosts

Environment (please complete the following information):

  • Node Version: All
  • Package Version: 1.0.0
  • OS Version: All

Additional context
NA

types error on production build

Describe the bug
On running a production build including the praxios module, getting a type error

To Reproduce
Steps to reproduce the behavior:

  1. Use it in any app
  2. Run it with NODE_ENV=production

Expected behavior
Module should work

Screenshots
image

Environment (please complete the following information):

  • Node Version: v14
  • Package Version: 1.0.2
  • OS Version: Linux

Additional context
NA

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.