Skip to content

Commit 7d7d207

Browse files
committed
docs: update readme with same guidance on proxying
1 parent 06dfbb6 commit 7d7d207

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,16 @@ const es = new EventSource('https://my-server.com/sse', {
134134

135135
#### HTTP/HTTPS proxy
136136

137-
Use a package like [`node-fetch-native`](https://github.com/unjs/node-fetch-native) to add proxy support, either through environment variables or explicit configuration.
137+
Use a package like [`undici`](https://github.com/nodejs/undici) to add proxy support, either through environment variables or explicit configuration.
138138

139139
```ts
140-
// npm install node-fetch-native --save
141-
import {fetch} from 'node-fetch-native/proxy'
140+
// npm install undici --save
141+
import {fetch, EnvHttpProxyAgent} from 'undici'
142+
143+
const proxyAgent = new EnvHttpProxyAgent()
142144

143145
const es = new EventSource('https://my-server.com/sse', {
144-
fetch: (input, init) => fetch(input, init),
146+
fetch: (input, init) => fetch(input, {...init, dispatcher: proxyAgent}),
145147
})
146148
```
147149

@@ -153,12 +155,14 @@ Use a package like [`undici`](https://github.com/nodejs/undici) for more control
153155
// npm install undici --save
154156
import {fetch, Agent} from 'undici'
155157

158+
const unsafeAgent = new Agent({
159+
connect: {
160+
rejectUnauthorized: false,
161+
},
162+
})
163+
156164
await fetch('https://my-server.com/sse', {
157-
dispatcher: new Agent({
158-
connect: {
159-
rejectUnauthorized: false,
160-
},
161-
}),
165+
dispatcher: unsafeAgent,
162166
})
163167
```
164168

0 commit comments

Comments
 (0)