From bf6de4a95974ef3100437698e9cd26973e52fcdc Mon Sep 17 00:00:00 2001 From: junjeong Date: Thu, 24 Apr 2025 18:33:01 +0900 Subject: [PATCH] =?UTF-8?q?fix:=201.=ED=99=88=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EC=97=90=EC=84=9C=20token=EC=9D=B4=20=EC=97=86=EC=96=B4=20erro?= =?UTF-8?q?r=20=EB=82=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C,=202.StrokeBanner?= =?UTF-8?q?=20=ED=81=B4=EB=A6=AD=EC=8B=9C=20fast-freind=EB=A1=9C=20?= =?UTF-8?q?=EA=B0=80=EB=8A=94=EB=AC=B8=EC=A0=9C,=203.production=20mode?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=9D=BC=EC=84=9C=20kakao-login=20redirec?= =?UTF-8?q?tUrl=20=EB=8B=A4=EB=A5=B4=EA=B2=8C=20=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=9E=90=EB=8F=99=ED=99=94=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/StrokeBanner.tsx | 2 +- src/components/button/KakaoLoginButton.tsx | 5 ++++- src/pages/SelectInfo.tsx | 4 ++-- src/store/useAuthStore.ts | 13 ++++++++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/StrokeBanner.tsx b/src/components/StrokeBanner.tsx index 092041f..dfd6983 100644 --- a/src/components/StrokeBanner.tsx +++ b/src/components/StrokeBanner.tsx @@ -5,7 +5,7 @@ const StrokeBanner = () => { const handleNavigate = () => { const mode = "virtualFriend"; - navigate("/select-info", { state: mode }); + navigate("/select-info", { state: { type: mode } }); }; return ( diff --git a/src/components/button/KakaoLoginButton.tsx b/src/components/button/KakaoLoginButton.tsx index cec87b4..c141073 100644 --- a/src/components/button/KakaoLoginButton.tsx +++ b/src/components/button/KakaoLoginButton.tsx @@ -1,6 +1,9 @@ const KakaoLoginButton = () => { const kakaoRestApiKey = import.meta.env.VITE_KAKAO_REST_API_KEY; - const kakaoRedirectUrl = import.meta.env.VITE_KAKAO_REDIRECT_URI; + const kakaoRedirectUrl = + import.meta.env.MODE === "production" + ? import.meta.env.VITE_KAKAO_PRODUCTION_REDIRECT_URI + : import.meta.env.VITE_KAKAO_DEVELOP_REDIRECT_URI; const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=${kakaoRestApiKey}&redirect_uri=${kakaoRedirectUrl}&response_type=code`; diff --git a/src/pages/SelectInfo.tsx b/src/pages/SelectInfo.tsx index cf4c96c..87be9b8 100644 --- a/src/pages/SelectInfo.tsx +++ b/src/pages/SelectInfo.tsx @@ -3,7 +3,7 @@ import { useLocation, useNavigate } from "react-router-dom"; import FormButton from "@/components/button/FormButton"; import Header from "@/components/header/Header"; import { getMBTIgroup, mapAgeToNumber } from "@/utils/helpers"; -import instance from "@/api/axios"; +import { authInstance } from "@/api/axios"; import ToastMessage from "@/components/ToastMessage"; import { trackEvent } from "@/libs/analytics"; @@ -192,7 +192,7 @@ const SelectInfo = () => { type === "virtualFriend" ? "api/virtual-friend" : "api/fast-friend"; try { - const response = await instance.post( + const response = await authInstance.post( `/${apiUrl}`, selectedData ); diff --git a/src/store/useAuthStore.ts b/src/store/useAuthStore.ts index 92673b0..3bd3cca 100644 --- a/src/store/useAuthStore.ts +++ b/src/store/useAuthStore.ts @@ -16,13 +16,16 @@ const useAuthStore = create( accessToken: null, login: async (code: string) => { try { - const res = await instance.get( - `/api/kakao/login?code=${code}` - // + "&redirectUrl=https://localhost:5173/kakao-login" - ); + const requestURI = + // 아래 코드는 백엔드팀에서 작업해주시면 동일한 uri로 바뀔 예정 -> 4.24 정준영 + import.meta.env.MODE === "production" + ? `/api/kakao/login?code=${code}` + : `/api/kakao/login?code=${code}&redirectUrl=https://localhost:5173/kakao-login`; + + const res = await instance.get(requestURI); set({ isLoggedIn: true, - accessToken: res.data as string + accessToken: res.data.data as string }); return { ok: true