Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: MO 카카오톡으로 링크를 열 때, 홈으로 가는 오류 수정 #1697

Merged
merged 9 commits into from
Dec 17, 2024
10 changes: 8 additions & 2 deletions src/components/auth/oauth/OAuthCallback.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -43,8 +42,15 @@ const OAuthCallback: FC<OAuthCallbackProps> = ({ 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;
}

Expand Down
4 changes: 3 additions & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading