Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
yunochi committed Nov 25, 2024
2 parents 49203d9 + d1cc9b7 commit b185b71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/app/main/_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default function MainHeader() {

const fetchMyProfile = async () => {
const user_handle = localStorage.getItem('user_handle');
const now = Math.ceil(Date.now() / 1000);

if (user_handle) {
const res = await fetch('/api/db/fetch-my-profile', {
Expand All @@ -28,11 +27,6 @@ export default function MainHeader() {
}
return;
}
// JWT 리프레시로부터 1시간이 지난 경우 refresh 시도
const last_token_refresh = Number.parseInt(localStorage.getItem('last_token_refresh') ?? '0');
if (now - last_token_refresh > 3600) {
await refreshJwt();
}
const data = await res.json();
return data;
}
Expand All @@ -42,6 +36,17 @@ export default function MainHeader() {
fetchMyProfile().then((r) => setUser(r));
}, []);

useEffect(() => {
const fn = async () => {
const now = Math.ceil(Date.now() / 1000);
// JWT 리프레시로부터 1시간이 지난 경우 refresh 시도
const last_token_refresh = Number.parseInt(localStorage.getItem('last_token_refresh') ?? '0');
if (now - last_token_refresh > 3600) {
await refreshJwt();
}
};
fn();
}, []);
return (
<div className="w-[90%] window:w-[80%] desktop:w-[70%] navbar bg-base-100 shadow rounded-box my-4">
<div className="flex-1">
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default function Home() {
setIsLoading(false);
};
fn();
});
}, []);

return (
<div className="w-screen h-screen absolute flex flex-col items-center justify-center">
Expand Down

0 comments on commit b185b71

Please sign in to comment.