Node.js built-in fetch API with undici. Use the native fetch with KnoxProxy through a ProxyAgent for zero-dependency proxy support.
For the ProxyAgent dispatcher.
npm install undiciUse undici ProxyAgent.
const { ProxyAgent } = require('undici');
const agent = new ProxyAgent('http://USER:PASS@gw.knoxproxy.com:7000');Pass dispatcher to fetch.
const res = await fetch('https://httpbin.org/ip', { dispatcher: agent });
const data = await res.json();
console.log(data);Country in proxy URL username.
const deAgent = new ProxyAgent('http://USER-country-de:PASS@gw.knoxproxy.com:7000');Session ID in username.
const stickyAgent = new ProxyAgent('http://USER-session-abc:PASS@gw.knoxproxy.com:7000');Verify exit IP.
const res = await fetch('https://httpbin.org/ip', { dispatcher: agent });
console.log(await res.json());/**
* KnoxProxy + Node.js native fetch (undici ProxyAgent).
*/
import { ProxyAgent } from 'undici';
const agent = new ProxyAgent('http://USER:PASS@gw.knoxproxy.com:7000');
const res = await fetch('https://httpbin.org/ip', { dispatcher: agent });
const data = await res.json();
console.log('Exit IP:', data.origin);
// Country-targeted
const deAgent = new ProxyAgent('http://USER-country-de:PASS@gw.knoxproxy.com:7000');
const deRes = await fetch('https://httpbin.org/ip', { dispatcher: deAgent });
console.log('DE IP:', (await deRes.json()).origin);Each fetch call gets a fresh IP. Use -session-{id} in username for sticky sessions.
| Problem | Fix |
|---|---|
| UND_ERR_CONNECT_TIMEOUT | Check gateway host/port. Try increasing connect timeout. |
| fetch failed | Verify you are using { dispatcher: agent } in fetch options. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Node.js built-in fetch does not support proxies natively. You need undici ProxyAgent as the dispatcher to route through KnoxProxy.
Performance is similar for proxied requests since the bottleneck is network latency. Node fetch with undici has slightly lower overhead.
Use AbortSignal.timeout(30000) as the signal option, or set headersTimeout on the ProxyAgent constructor.
Bun and Deno have their own proxy support. For Bun, use the proxy env vars. For Deno, use the Deno.createHttpClient() API.
Free trial on rotating residential -- 3 minutes setup, no credit card.