Configure TrueProxies with Node.js
import axios from 'axios';
const response = await axios.get('https://httpbin.org/ip', { proxy: { host: 'YOUR_HOST', port: 8080, auth: { username: 'your_username', password: 'your_password' }, },});
console.log(response.data);import axios from 'axios';import { HttpsProxyAgent } from 'https-proxy-agent';
const agent = new HttpsProxyAgent( 'http://your_username:your_password@YOUR_HOST:YOUR_HTTP_PORT');
const response = await axios.get('https://httpbin.org/ip', { httpsAgent: agent,});
console.log(response.data);node-fetch
Section titled “node-fetch”import fetch from 'node-fetch';import { HttpsProxyAgent } from 'https-proxy-agent';
const agent = new HttpsProxyAgent( 'http://your_username:your_password@YOUR_HOST:YOUR_HTTP_PORT');
const response = await fetch('https://httpbin.org/ip', { agent });const data = await response.json();console.log(data);Native fetch (Node.js 18+)
Section titled “Native fetch (Node.js 18+)”import { ProxyAgent } from 'undici';
const proxyAgent = new ProxyAgent( 'http://your_username:your_password@YOUR_HOST:YOUR_HTTP_PORT');
const response = await fetch('https://httpbin.org/ip', { dispatcher: proxyAgent,});
const data = await response.json();console.log(data);SOCKS5
Section titled “SOCKS5”import axios from 'axios';import { SocksProxyAgent } from 'socks-proxy-agent';
const agent = new SocksProxyAgent( 'socks5://your_username:your_password@YOUR_HOST:YOUR_SOCKS_PORT');
const response = await axios.get('https://httpbin.org/ip', { httpsAgent: agent,});
console.log(response.data);Residential IPv4 country targeting
Section titled “Residential IPv4 country targeting”Append -country-XX to your username:
const agent = new HttpsProxyAgent( 'http://your_username-country-us:your_password@YOUR_HOST:YOUR_HTTP_PORT');Residential IPv4 sticky sessions
Section titled “Residential IPv4 sticky sessions”const agent = new HttpsProxyAgent( 'http://your_username-session-abc123:your_password@YOUR_HOST:YOUR_HTTP_PORT');