diff --git a/src/app/googleLogin/page.tsx b/src/app/googleLogin/page.tsx index 5977000..f30481f 100644 --- a/src/app/googleLogin/page.tsx +++ b/src/app/googleLogin/page.tsx @@ -1,7 +1,7 @@ 'use client'; import {useEffect} from 'react'; import Image from 'next/image'; -import {useRouter, useSearchParams} from 'next/navigation'; +import {useRouter} from 'next/navigation'; import Cookies from 'js-cookie'; import {useSetRecoilState} from 'recoil'; import userState from '@/src/recoil/atoms/userState'; @@ -9,11 +9,16 @@ import postGoogleLogin from '@/src/api/auth/postGoogleLogin'; import gifs from '@/public/gif'; import '@/src/styles/variable.css'; +export const dynamic = 'force-dynamic'; // 이 페이지는 클라이언트 측에서만 렌더링됨 + const Page = () => { - const code: string | null = useSearchParams().get('code'); const setUser = useSetRecoilState(userState); const router = useRouter(); + useEffect(() => { + const params = new URLSearchParams(window.location.search); + const code = params.get('code'); + if (code) { postGoogleLogin(code).then(res => { if (res.user) { @@ -26,7 +31,7 @@ const Page = () => { router.push('/classes'); }); } - }, []); + }, [router, setUser]); return (