ProxySeller
Integration guide

Use a proxy with Node.js (undici)

Node's built-in fetch does not read proxy settings by default. The undici package provides a ProxyAgent that does.

Get your details

Copy the host, port, username and password for your proxy from the dashboard. Where this page writes <host>, <port>, <username> or <password>, paste your own values.

Install undici

npm install undici

Send a request

The token option sends a Basic authorisation header to the proxy.

import { ProxyAgent, fetch } from "undici";

const token = Buffer.from(
  `${process.env.PROXY_USER}:${process.env.PROXY_PASS}`,
).toString("base64");

const dispatcher = new ProxyAgent({
  uri: `http://${process.env.PROXY_HOST}:${process.env.PROXY_PORT}`,
  token: `Basic ${token}`,
});

const res = await fetch("https://api.ipify.org", { dispatcher });
console.log(await res.text());

Keep reading

Ready to connect?

Create an account and copy your proxy details from the dashboard.

Create an account