Skip to content

Commit fa4694d

Browse files
committed
feat: add OAuth proxy support in auth configuration
1 parent f74ff71 commit fa4694d

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

packages/auth/src/configs/auth.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
bearer,
88
magicLink,
99
multiSession,
10+
oAuthProxy,
1011
oneTap,
1112
openAPI,
1213
organization,
@@ -111,6 +112,8 @@ export const DEVELOPMENT_ORIGINS = [
111112

112113
export const MAX_SESSIONS = 2;
113114

115+
const USE_OAUTH_PROXY = true;
116+
114117
const getBaseURL = (envUrl: string | undefined): string => {
115118
try {
116119
if (!envUrl) {
@@ -205,6 +208,14 @@ export function createAuthConfig(env: Env) {
205208
},
206209
},
207210
plugins: [
211+
...(USE_OAUTH_PROXY
212+
? [
213+
oAuthProxy({
214+
currentURL: baseAuthURL,
215+
productionURL: appURL,
216+
}),
217+
]
218+
: []),
208219
admin(),
209220
oneTap(),
210221
bearer(),
@@ -358,10 +369,16 @@ export function createAuthConfig(env: Env) {
358369
github: {
359370
clientId: env.GITHUB_CLIENT_ID,
360371
clientSecret: env.GITHUB_CLIENT_SECRET,
372+
redirectURI: USE_OAUTH_PROXY
373+
? `${baseAuthURL}/api/auth/callback/github`
374+
: undefined,
361375
},
362376
google: {
363377
clientId: env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
364378
clientSecret: env.GOOGLE_CLIENT_SECRET,
379+
redirectURI: USE_OAUTH_PROXY
380+
? `${baseAuthURL}/api/auth/callback/google`
381+
: undefined,
365382
},
366383
},
367384
account: {

0 commit comments

Comments
 (0)