node-cookie-proxy-agent
Install
npm install node-cookie-proxy-agent http-proxy-agent https-proxy-agent tough-cookie
Usage
Pass http-cookie-agent
to HTTP clients instead of http(s).Agent.
import axios from 'axios';
import { HttpCookieProxyAgent, HttpsCookieProxyAgent } from 'node-cookie-proxy-agent';
import { CookieJar } from 'tough-cookie';
(async () => {
const jar = new CookieJar();
const httpAgent = new HttpCookieProxyAgent(jar, 'http://127.0.0.1:8888');
const httpsAgent = new HttpsCookieProxyAgent(jar, 'http://127.0.0.1:8888');
const axiosClient = axios.create({ httpAgent, httpsAgent });
console.log('result: ', (await axiosClient.get('https://api.ipify.org?format=json')).data);
})().catch(err => console.error(err));