Skip to content

Commit 06dfbb6

Browse files
committed
docs: update migration guide with better guidance on proxying
1 parent d4385cb commit 06dfbb6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

MIGRATION.md

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

6262
#### HTTP/HTTPS proxy dropped
6363

64-
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.
64+
Use a package like [`undici`](https://github.com/nodejs/undici) to add proxy support, either through environment variables or explicit configuration.
6565

6666
```ts
67-
// npm install node-fetch-native --save
68-
import {fetch} from 'node-fetch-native/proxy'
67+
// npm install undici --save
68+
import {fetch, EnvHttpProxyAgent} from 'undici'
69+
70+
const proxyAgent = new EnvHttpProxyAgent()
6971

7072
const es = new EventSource('https://my-server.com/sse', {
71-
fetch: (input, init) => fetch(input, init),
73+
fetch: (input, init) => fetch(input, {...init, dispatcher: proxyAgent}),
7274
})
7375
```
7476

@@ -80,12 +82,14 @@ Use a package like [`undici`](https://github.com/nodejs/undici) for more control
8082
// npm install undici --save
8183
import {fetch, Agent} from 'undici'
8284

85+
const unsafeAgent = new Agent({
86+
connect: {
87+
rejectUnauthorized: false,
88+
},
89+
})
90+
8391
await fetch('https://my-server.com/sse', {
84-
dispatcher: new Agent({
85-
connect: {
86-
rejectUnauthorized: false,
87-
},
88-
}),
92+
dispatcher: unsafeAgent,
8993
})
9094
```
9195

0 commit comments

Comments
 (0)