Skip to content

Commit

Permalink
๐Ÿ”ง fix: logout api ํ˜ธ์ถœํ•˜๋„๋ก ๋ณ€๊ฒฝ
Browse files Browse the repository at this point in the history
  • Loading branch information
dongree committed Nov 21, 2024
1 parent f942ef0 commit c739e1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 6 additions & 4 deletions FE/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export default function Header() {
check();
}, [setIsLogin]);

const handleLogout = () => {
setIsLogin(false);
deleteCookie('accessToken');
};

return (
<header className='fixed left-0 top-0 h-[60px] w-full bg-white'>
<div className='mx-auto flex h-full max-w-[1280px] items-center justify-between px-8'>
Expand Down Expand Up @@ -52,10 +57,7 @@ export default function Header() {
{isLogin ? (
<button
className='px-4 py-2 text-sm text-juga-grayscale-500'
onClick={() => {
setIsLogin(false);
deleteCookie('accessToken');
}}
onClick={handleLogout}
>
๋กœ๊ทธ์•„์›ƒ
</button>
Expand Down
11 changes: 11 additions & 0 deletions FE/src/service/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ export async function checkAuth() {
headers: { 'Content-Type': 'application/json' },
});
}

export async function logout() {
const url = import.meta.env.PROD
? `${import.meta.env.VITE_API_URL}/auth/logout`
: '/api/auth/logout';

return fetch(url, {
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
});
}

0 comments on commit c739e1f

Please sign in to comment.