Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/button/KakaoLoginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const KakaoLoginButton = () => {
const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=${import.meta.env.VITE_KAKAO_REST_API_KEY}&redirect_uri=${import.meta.env.VITE_KAKAO_REDIRECT_URI}&response_type=code`;
const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=3e5cfa29037d1bd11eb5448f9b298bfe&redirect_uri=https://localhost:5173/kakao-login&response_type=code`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

임시로 로컬에서만 동작하도록 처리하신걸까요?

Copy link
Collaborator Author

@junjeeong junjeeong Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이제 보니 잘못하고 loclahost로 넣었네요...배포 주소로 변경하겠습니다 ㅎㅎ


const handleClick = () => {
window.location.href = kakaoURL;
Expand All @@ -9,7 +9,7 @@ const KakaoLoginButton = () => {
<button
type="button"
onClick={handleClick}
className="flex justify-center items-center bg-[#F9E622] hover:opacity-80 rounded-lg w-[320px] h-[56px] font-bold text-black"
className="flex h-[56px] w-[320px] items-center justify-center rounded-lg bg-[#F9E622] font-bold text-black hover:opacity-80"
>
카카오로 시작하기
</button>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/KaKaoLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const KaKaoLogin = () => {
const getTokenAndLogin = async () => {
if (typeof code === "string") {
try {
await login(code);
navigate("/");
const res = await login(code);
if (res.ok) navigate("/");
} catch (err) {
console.error("카카오 로그인에 실패했습니다.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가하신 엣지케이스 연결하면 좋을 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c632e2d 반영했습니다!

}
Expand Down
19 changes: 12 additions & 7 deletions src/store/useAuthStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import instance from "@/api/axios";
interface AuthStore {
isLoggedIn: boolean;
accessToken: string | null;
login: (code: string) => Promise<void>;
login: (code: string) => Promise<{ ok: boolean }>;
logout: () => void;
}

Expand All @@ -17,21 +17,26 @@ const useAuthStore = create(
login: async (code: string) => {
try {
const res = await instance.get(`/api/kakao/login?code=${code}`);
if (res.data) {
set({
isLoggedIn: true,
accessToken: res.data as string
});
}
set({
isLoggedIn: true,
accessToken: res.data as string
});
return {
ok: true
};
} catch (error) {
console.error("Error during login:", error);
return {
ok: false
};
}
},
logout: () => {
set({
isLoggedIn: false,
accessToken: null
});
return { ok: true };
}
}),
{
Expand Down