You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add pages for ky, wretch, make-fetch-happen, needle, typed-rest-client
- Extend index, getting-started, and testing for all adapters
- Point MkDocs nav and repo links at proxymesh/javascript-proxy-headers
- Core API: prefer needle adapter over raw agent example
Made-with: Cursor
For normal use, prefer the [needle adapter](needle.md) (`proxyNeedleGet` / `createProxyNeedle`), which merges CONNECT headers onto the response. To wire the agent yourself:
[ky](https://github.com/sindresorhus/ky) is a small HTTP client built on `fetch`. This package wires ky to a custom `fetch` implemented with [node-fetch](node-fetch.md) and `ProxyHeadersAgent`, so CONNECT proxy headers work the same way as in the node-fetch adapter.
4
+
5
+
## Getting Started
6
+
7
+
### Prerequisites
8
+
9
+
```bash
10
+
npm install javascript-proxy-headers ky node-fetch
11
+
```
12
+
13
+
`node-fetch` is required because the underlying `fetch` is shared with the node-fetch integration.
Creates a ky instance (`ky.create`) whose `fetch` sends custom headers on the proxy CONNECT and surfaces CONNECT response headers on each `Response` as `proxyHeaders`.
Responses are [`ProxyResponse`](node-fetch.md) instances: use `response.proxyHeaders.get('x-proxymesh-ip')` (and the usual `response.json()`, `response.text()`, etc.). Proxy CONNECT failures use the same errors as the underlying fetch stack; see [Core API](core-api.md) for `ConnectError` on the agent.
[make-fetch-happen](https://github.com/npm/make-fetch-happen) is npm’s fetch implementation (caching, retries, proxy integration). This package supplies a `ProxyHeadersAgent` as the `agent` option so `@npmcli/agent` uses it as-is, and wraps the returned `Response` so CONNECT response headers are available.
[needle](https://github.com/tomas/needle) is a lean HTTP client for Node. This package routes HTTPS through `ProxyHeadersAgent` and merges CONNECT response headers into the needle response where the same keys are not already set.
// CONNECT headers merged into res.headers when missing
25
+
console.log(res.headers['x-proxymesh-ip']);
26
+
console.log(res.proxyAgent.lastProxyHeaders);
27
+
```
28
+
29
+
## API Reference
30
+
31
+
### proxyNeedleGet(url, options)
32
+
33
+
Promise-based GET with proxy headers. Needle’s proxy handling is disabled (`proxy: null`, `use_proxy_from_env_var: false`) so only `ProxyHeadersAgent` is used.
0 commit comments