diff --git a/src/components/auth/oauth/OAuthCallback.tsx b/src/components/auth/oauth/OAuthCallback.tsx index d466f41a9..78f08ea54 100644 --- a/src/components/auth/oauth/OAuthCallback.tsx +++ b/src/components/auth/oauth/OAuthCallback.tsx @@ -1,5 +1,4 @@ import styled from '@emotion/styled'; -import { colors } from '@sopt-makers/colors'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { FC, useEffect, useState } from 'react'; @@ -43,8 +42,15 @@ const OAuthCallback: FC = ({ url }) => { } if (!accessToken) { - lastUnauthorized.setPath(url.href); + const returnUrl = new URLSearchParams(window.location.search).get('returnUrl'); + + if (returnUrl) { + lastUnauthorized.setPath(decodeURIComponent(returnUrl)); + } else { + lastUnauthorized.setPath(url.href); + } location.href = playgroundLink.login(); + return; } diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 018c8cffe..9a46d23e3 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -83,7 +83,9 @@ function MyApp({ Component, pageProps }: AppProps) { if (useragt.match(/kakaotalk/i)) { // MEMO: 카카오톡 외부브라우저로 호출 - location.href = 'kakaotalk://web/openExternal?url=' + encodeURIComponent(target_url); + const encodedReturnUrl = encodeURIComponent(target_url); + + location.href = `kakaotalk://web/openExternal?url=${encodedReturnUrl}&returnUrl=${encodedReturnUrl}`; } else if ( useragt.match( /inapp|naver|snapchat|wirtschaftswoche|thunderbird|instagram|everytimeapp|whatsApp|electron|wadiz|aliapp|zumapp|iphone(.*)whale|android(.*)whale|kakaostory|band|twitter|DaumApps|DaumDevice\/mobile|FB_IAB|FB4A|FBAN|FBIOS|FBSS|trill|SamsungBrowser\/[^1]/i,