Variable customFetchConst

customFetch: unique symbol

:::danger This option allows you to override the default fetch function used by the provider to make requests to the provider's OAuth endpoints directly. Used incorrectly, it can have security implications. :::

It can be used to support corporate proxies, custom fetch libraries, cache discovery endpoints, add mocks for testing, logging, set custom headers/params for non-spec compliant providers, etc.

import { Auth, customFetch } from "@auth/core"
import GitHub from "@auth/core/providers/github"

const dispatcher = new ProxyAgent("my.proxy.server")
function proxy(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {
return undici(args[0], { ...(args[1] ?? {}), dispatcher })
}

const response = await Auth(request, {
providers: [GitHub({ [customFetch]: proxy })]
})