Skip to content

Commit 74d2346

Browse files
docs: Update corporate-proxy.mdx
1 parent fedff04 commit 74d2346

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/pages/guides/corporate-proxy.mdx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@ import { Code } from "@/components/Code"
22

33
# Supporting corporate proxies
44

5-
Auth.js libraries like NextAuth.js use the `fetch` API to communicate with OAuth providers. If your organization uses a corporate proxy, you may need to configure the `fetch` API to use the proxy.
5+
Auth.js libraries use the `fetch` API to communicate with OAuth providers. If your organization uses a corporate proxy, you may need to configure the `fetch` API to use the proxy.
66

77
## Using a custom fetch function
88

9-
You can provide a custom `fetch` function to NextAuth.js by passing it as an option to the provider. This allows you to configure the `fetch` function to use a proxy.
9+
You can provide a custom `fetch` function by passing it as an option to the provider.
1010

11-
Here, we use the `undici` library to make requests through a proxy server. We create a custom `fetch` function that uses `undici` and the `ProxyAgent` library to make requests through the proxy server.
11+
Here, we use the `undici` library to make requests through a proxy server, by passing a `dispatcher` to the `fetch` implementation by `undici`.
1212

1313
<Code>
1414
<Code.Next>
1515

1616
```tsx filename="auth.ts"
1717
import NextAuth, { customFetch } from "next-auth"
1818
import GitHub from "next-auth/providers/github"
19+
import { ProxyAgent, fetch as undici } from "undici"
1920

2021
const dispatcher = new ProxyAgent("my.proxy.server")
2122
function proxy(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {
@@ -30,3 +31,7 @@ export const { handlers, auth } = NextAuth({
3031

3132
</Code.Next>
3233
</Code>
34+
35+
## Resources
36+
37+
- [`undici` - Basic Proxy Request with local agent dispatcher](https://undici.nodejs.org/#/docs/api/ProxyAgent?id=example-basic-proxy-request-with-local-agent-dispatcher)

0 commit comments

Comments
 (0)