Integration · JavaScript
Node.js
Undici's ProxyAgent with the built-in fetch.
Install
npm install undiciExample
import { ProxyAgent, fetch } from "undici";
const dispatcher = new ProxyAgent("http://USERNAME:PASSWORD@GATEWAY_HOST:PORT");
const response = await fetch("https://httpbin.org/ip", { dispatcher });
console.log(await response.json());Replace USERNAME, PASSWORD, GATEWAY_HOST and PORT with the values in your dashboard. Never commit them.
Notes
- Node's global fetch does not read proxy environment variables by default. Pass the dispatcher explicitly.
Common errors
| 407 Proxy Authentication Required | Cause. Credentials missing, mistyped, or not URL-encoded. Fix. Percent-encode special characters in the username and password, or pass credentials separately from the URL where the client allows it. |
|---|---|
| Timeouts on first request | Cause. Wrong gateway host or port, or an outbound firewall rule on your side. Fix. Copy host and port from the dashboard entry for your product and test with curl first. |
Next: measure it on your real target.