Skip to content

Commit 9cc2fc1

Browse files
committed
Add missing /oauth/authorize passthrough endpoint
When I refactored the OAuth flow to allow proxying through the application server, I changed the behavior of the default authorize endpoint to point at the application server but did not add a default handler there to call through to the server and get the correct authorize endpoint to redirect the user's browser to the IdP.
1 parent d47fd12 commit 9cc2fc1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/auth-nextjs/src/shared.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ export abstract class NextAuth extends NextAuthHelpers {
161161
* @param {string=} req.nextUrl.searchParams.provider_name The name of the
162162
* OAuth provider to use.
163163
* @param {string=} req.nextUrl.searchParams.authorize_url The URL to
164-
* redirect to to start the OAuth flow. If not provided, will default to
165-
* the auth extension server's authorize endpoint.
164+
* redirect to to start the OAuth flow. Will default to calling through to
165+
* the auth extension server's authorize endpoint from the registered
166+
* endpoint at `/oauth/authorize`.
166167
* @param {string=} req.nextUrl.searchParams.callback_url The URL to
167168
* redirect to within the OAuth flow once the user has authorized the OAuth
168169
* client.
@@ -184,7 +185,7 @@ export abstract class NextAuth extends NextAuthHelpers {
184185

185186
const authorizeUrl =
186187
req.nextUrl.searchParams.get("authorize_url") ??
187-
new URL("authorize", this.options.baseUrl).toString();
188+
new URL("authorize", authBasePath).toString();
188189

189190
const pkceSession = await (await this.core).createPKCESession();
190191
await this.setVerifierCookie(pkceSession.verifier);
@@ -282,6 +283,9 @@ export abstract class NextAuth extends NextAuthHelpers {
282283
}
283284
return this.oAuth.handleOAuth(req);
284285
}
286+
case "oauth/authorize": {
287+
return this.oAuth.handleAuthorize(req);
288+
}
285289
case "oauth/callback": {
286290
if (!onOAuthCallback) {
287291
throw new ConfigurationError(

0 commit comments

Comments
 (0)