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
Pass an HttpsProxyAgent as Axios's httpAgent and httpsAgent, then set proxy: false so Axios does not apply a second proxy configuration. Install axios and https-proxy-agent, and store the complete dashboard HTTP(S) proxy 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
Use SocksProxyAgent for an authenticated SOCKS5 URL and pass it as both Axios agents with proxy: false. Install socks-proxy-agent and use the dashboard'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.
