Skip to content

A wrapper over the axios library to support corporate proxies well

License

Notifications You must be signed in to change notification settings

Safe-Security/praxios

Repository files navigation

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