JavaScript / TypeScript Proxy Server Integration Guide
JavaScript and TypeScript are widely used for web scraping, API clients, and server-side applications in Node.js. Whether you're building a scraper, aggregating data, or need anonymous HTTP requests, using a rotating proxy server helps avoid IP bans and rate limits.
ProxyMesh provides rotating proxy servers that work with popular JavaScript HTTP clients. Our proxy servers automatically rotate IP addresses so each request can use a different IP. This guide covers configuring Node.js and TypeScript applications to use ProxyMesh for reliable, scalable requests.
Quick Start: JavaScript Proxy Setup
Get started with ProxyMesh rotating proxies in three steps:
- Sign up for a free ProxyMesh trial to get your proxy credentials
- Install your preferred HTTP library and
javascript-proxy-headers(for custom headers over HTTPS) - Configure the proxy URL with your ProxyMesh server address
Basic Example with Axios
import { createProxyAxios } from 'javascript-proxy-headers/axios';
const client = createProxyAxios({
proxy: 'http://username:password@proxyhost:31280',
proxyHeaders: { 'X-ProxyMesh-Country': 'US' }
});
const response = await client.get('https://api.ipify.org?format=json');
console.log(response.headers['x-proxymesh-ip']); // IP used by the proxy
Each request through ProxyMesh can use a different IP address from our rotating pool.
Package sources
Install from npm or JSR:
# npm
npm install javascript-proxy-headers axios
# JSR (JavaScript Registry)
npx jsr add @proxymesh/javascript-proxy-headers
npm install axios
JavaScript HTTP Libraries with Proxy Support
ProxyMesh works with popular Node.js HTTP clients. The javascript-proxy-headers package adds support for custom proxy headers (e.g. X-ProxyMesh-Country) during HTTPS CONNECT tunneling:
Axios
The most popular JavaScript HTTP client with a promise-based API. Perfect for APIs, web apps, and scraping. Use createProxyAxios() for proxy headers.
npm install axios javascript-proxy-headers
node-fetch
Lightweight Fetch API for Node.js. Use proxyFetch() from javascript-proxy-headers for custom proxy headers and response.proxyHeaders.
npm install node-fetch javascript-proxy-headers
Got
Human-friendly HTTP client with strong TypeScript support. Use createProxyGot() for proxy header support.
npm install got javascript-proxy-headers
Undici
Fast, spec-compliant HTTP client (used in Node.js core). Use request() from javascript-proxy-headers for proxy headers.
npm install undici javascript-proxy-headers
Superagent
Flexible, chainable HTTP client for Node.js and browsers. Use the proxy plugin from javascript-proxy-headers for custom headers.
npm install superagent javascript-proxy-headers
ky
Tiny Fetch API–based HTTP client. Use createProxyKy() from javascript-proxy-headers for custom proxy CONNECT headers.
npm install ky javascript-proxy-headers
wretch
Chainable fetch wrapper. Use createProxyWretch() for proxy header support and response.proxyHeaders.
npm install wretch javascript-proxy-headers
make-fetch-happen
npm’s fetch implementation with agents and caching. Use createProxyMakeFetchHappen() for CONNECT headers.
npm install make-fetch-happen javascript-proxy-headers
Needle
Lightweight HTTP client for Node.js. Use proxyNeedleGet() for custom proxy headers merged into response headers.
npm install needle javascript-proxy-headers
typed-rest-client
Microsoft’s typed REST client. Use createProxyRestClient() for HTTPS via ProxyHeadersAgent.
npm install typed-rest-client javascript-proxy-headers
Why Use ProxyMesh for JavaScript Web Scraping?
Automatic IP Rotation
Every request through ProxyMesh can use a different IP address from our rotating pool. Each location maintains multiple IPs that rotate throughout the day, giving you access to hundreds of unique addresses without code changes. This automatic rotation helps you:
- Avoid IP bans when scraping websites
- Bypass rate limiting based on IP address
- Distribute requests for better anonymity
Multiple Geographic Locations
ProxyMesh operates proxy servers worldwide in 17 locations:
- Los Angeles, CA, US
- Seattle, WA, US
- Paris, France
- Tokyo, Japan
- Sydney, Australia
- Frankfurt, Germany
- Amsterdam, Netherlands
- Singapore
- Chicago, IL, US
- Dallas, TX, US
- Washington DC, US
- New York, NY, US
- London, UK
- Zurich, Switzerland
- Orlando, FL, US
- Mumbai, India
- Open Proxy Server
- World Proxy Server
- US ISP Proxy Server
Access geo-restricted content or test how your application appears from different regions by connecting to the appropriate proxy location.
Simple Authentication
ProxyMesh supports two authentication methods:
- Username/Password: Include credentials in the proxy URL:
http://username:password@proxyhost:31280 - IP Authentication: Whitelist your server's IP in the dashboard—no credentials needed in code
Custom Headers over HTTPS
The javascript-proxy-headers package lets you send headers like X-ProxyMesh-Country during HTTPS CONNECT tunneling and read X-ProxyMesh-IP from the proxy response. Available on npm and JSR.
Documentation and Resources
ProxyMesh Documentation
- HTTP Proxy Configuration Guide
- Proxy Server Locations
- Proxy Authentication Options
- Custom Headers Reference
Packages and Examples
- javascript-proxy-headers on npm
- @proxymesh/javascript-proxy-headers on JSR
- javascript-proxy-headers on GitHub
- JavaScript Proxy Examples on GitHub
Frequently Asked Questions
What is the best JavaScript library for proxy requests?
Axios is the most popular JavaScript HTTP client and has excellent proxy support. For Fetch API compatibility in Node.js, use node-fetch, or smaller wrappers like ky and wretch. For maximum performance, Undici (used in Node.js core) is the fastest. Got is a human-friendly alternative with strong TypeScript support.
How do I configure a rotating proxy in Node.js?
Configure a rotating proxy by setting the proxy option in your HTTP client to a ProxyMesh server address. ProxyMesh automatically rotates IP addresses on each request. Use the javascript-proxy-headers package for custom proxy headers (e.g., X-ProxyMesh-Country) over HTTPS.
Does ProxyMesh work with TypeScript?
Yes, ProxyMesh works with both JavaScript and TypeScript. The javascript-proxy-headers package includes TypeScript types and is published on both npm and JSR. Use it with any supported HTTP client (Axios, node-fetch, Got, Undici, Superagent, ky, wretch, make-fetch-happen, Needle, typed-rest-client).
Where can I install javascript-proxy-headers?
Install from npm: npm install javascript-proxy-headers. Or from JSR (JavaScript Registry): npx jsr add @proxymesh/javascript-proxy-headers. The package has no dependencies by default—install only the HTTP library you need (e.g., axios, node-fetch).