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