From 93734d2c9a072b18353f935f9cb97cca9a78dd87 Mon Sep 17 00:00:00 2001 From: Junyan Chin Date: Tue, 10 Feb 2026 12:32:39 +0800 Subject: [PATCH] fix(web): redirect to OAuth authorize page after login instead of /apps (#32177) Co-authored-by: Claude Opus 4.6 --- web/app/page.tsx | 23 ++++++++++++++++++--- web/app/signin/utils/post-login-redirect.ts | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/web/app/page.tsx b/web/app/page.tsx index 117d6c838d..ddb49655d3 100644 --- a/web/app/page.tsx +++ b/web/app/page.tsx @@ -1,7 +1,24 @@ -import Link from 'next/link' -import Loading from '@/app/components/base/loading' +'use client' + +import Link from 'next/link' +import { useRouter } from 'next/navigation' +import { useEffect } from 'react' +import Loading from '@/app/components/base/loading' +import { OAUTH_AUTHORIZE_PENDING_KEY } from '@/app/account/oauth/authorize/constants' +import { getOAuthPendingRedirect } from '@/app/signin/utils/post-login-redirect' + +const Home = () => { + const router = useRouter() + + useEffect(() => { + const pendingRedirect = getOAuthPendingRedirect(OAUTH_AUTHORIZE_PENDING_KEY) + if (pendingRedirect) { + router.replace(pendingRedirect) + return + } + router.replace('/apps') + }, [router]) -const Home = async () => { return (
diff --git a/web/app/signin/utils/post-login-redirect.ts b/web/app/signin/utils/post-login-redirect.ts index b548a1bac9..5b455cd1d1 100644 --- a/web/app/signin/utils/post-login-redirect.ts +++ b/web/app/signin/utils/post-login-redirect.ts @@ -2,7 +2,7 @@ import type { ReadonlyURLSearchParams } from 'next/navigation' import dayjs from 'dayjs' import { OAUTH_AUTHORIZE_PENDING_KEY, REDIRECT_URL_KEY } from '@/app/account/oauth/authorize/constants' -function getItemWithExpiry(key: string): string | null { +export function getOAuthPendingRedirect(key: string): string | null { const itemStr = localStorage.getItem(key) if (!itemStr) return null @@ -33,5 +33,5 @@ export const resolvePostLoginRedirect = (searchParams: ReadonlyURLSearchParams) } } - return getItemWithExpiry(OAUTH_AUTHORIZE_PENDING_KEY) + return getOAuthPendingRedirect(OAUTH_AUTHORIZE_PENDING_KEY) }