Skip to content

Commit bf6de4a

Browse files
committed
fix: 1.홈페이지에서 token이 없어 error 나는 문제, 2.StrokeBanner 클릭시 fast-freind로 가는문제, 3.production mode에 따라서 kakao-login redirectUrl 다르게 하는 부분 자동화 추가
1 parent d9d2c59 commit bf6de4a

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

src/components/StrokeBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const StrokeBanner = () => {
55

66
const handleNavigate = () => {
77
const mode = "virtualFriend";
8-
navigate("/select-info", { state: mode });
8+
navigate("/select-info", { state: { type: mode } });
99
};
1010

1111
return (

src/components/button/KakaoLoginButton.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const KakaoLoginButton = () => {
22
const kakaoRestApiKey = import.meta.env.VITE_KAKAO_REST_API_KEY;
3-
const kakaoRedirectUrl = import.meta.env.VITE_KAKAO_REDIRECT_URI;
3+
const kakaoRedirectUrl =
4+
import.meta.env.MODE === "production"
5+
? import.meta.env.VITE_KAKAO_PRODUCTION_REDIRECT_URI
6+
: import.meta.env.VITE_KAKAO_DEVELOP_REDIRECT_URI;
47

58
const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=${kakaoRestApiKey}&redirect_uri=${kakaoRedirectUrl}&response_type=code`;
69

src/pages/SelectInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useLocation, useNavigate } from "react-router-dom";
33
import FormButton from "@/components/button/FormButton";
44
import Header from "@/components/header/Header";
55
import { getMBTIgroup, mapAgeToNumber } from "@/utils/helpers";
6-
import instance from "@/api/axios";
6+
import { authInstance } from "@/api/axios";
77
import ToastMessage from "@/components/ToastMessage";
88
import { trackEvent } from "@/libs/analytics";
99

@@ -192,7 +192,7 @@ const SelectInfo = () => {
192192
type === "virtualFriend" ? "api/virtual-friend" : "api/fast-friend";
193193

194194
try {
195-
const response = await instance.post<FriendResponse>(
195+
const response = await authInstance.post<FriendResponse>(
196196
`/${apiUrl}`,
197197
selectedData
198198
);

src/store/useAuthStore.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ const useAuthStore = create(
1616
accessToken: null,
1717
login: async (code: string) => {
1818
try {
19-
const res = await instance.get(
20-
`/api/kakao/login?code=${code}`
21-
// + "&redirectUrl=https://localhost:5173/kakao-login"
22-
);
19+
const requestURI =
20+
// 아래 코드는 백엔드팀에서 작업해주시면 동일한 uri로 바뀔 예정 -> 4.24 정준영
21+
import.meta.env.MODE === "production"
22+
? `/api/kakao/login?code=${code}`
23+
: `/api/kakao/login?code=${code}&redirectUrl=https://localhost:5173/kakao-login`;
24+
25+
const res = await instance.get(requestURI);
2326
set({
2427
isLoggedIn: true,
25-
accessToken: res.data as string
28+
accessToken: res.data.data as string
2629
});
2730
return {
2831
ok: true

0 commit comments

Comments
 (0)