Integration
How to Use Proxies With Node.js
In Node.js, an explicit proxy agent gives predictable behavior for authenticated HTTP and SOCKS5 connections. Pass the agent to both HTTP and HTTPS request options and disable Axios's separate proxy parsing.
HTTP(S) with Axios
Install axios and https-proxy-agent. Store the complete dashboard URL in PROXY_URL.
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";
const agent = new HttpsProxyAgent(process.env.PROXY_URL);
const { data } = await axios.get("https://ipinfo.io/json", {
httpAgent: agent,
httpsAgent: agent,
proxy: false,
timeout: 30_000,
});
console.log(data);SOCKS5 with Axios
Install socks-proxy-agent and use the SOCKS5 URL from the dashboard. That URL uses the provider's separate SOCKS5 port.
import axios from "axios";
import { SocksProxyAgent } from "socks-proxy-agent";
const agent = new SocksProxyAgent(process.env.SOCKS5_PROXY_URL);
const { data } = await axios.get("https://ipinfo.io/json", {
httpAgent: agent,
httpsAgent: agent,
proxy: false,
timeout: 30_000,
});
console.log(data);Keep credentials out of logs
A proxy URL contains a live username and password. Do not print the agent configuration, commit .env files, or include the full URL in error telemetry. Redact authentication before recording connection errors.
- Use environment variables or a secret manager.
- Rotate the password from the dashboard after exposure.
- Avoid embedding credentials in client-side browser code.
Reuse agents deliberately
Reusing one agent can reduce connection overhead. Sticky identity comes from the generated session parameters, not merely from keeping a Node object alive. Use one generated credential per intended sticky session.
