Skip to content

Commit 502ccd6

Browse files
Merge pull request #46 from sparcs-kaist/dev
Repository Setting
2 parents 8d3c942 + 21c81a8 commit 502ccd6

File tree

14 files changed

+709
-50
lines changed

14 files changed

+709
-50
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
NODE_ENV=development
2-
API_URL=https://newara.dev.sparcs.org/
2+
NEXT_PUBLIC_API_HOST=

package-lock.json

Lines changed: 102 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"axios": "^1.10.0",
1213
"i18next": "^24.2.2",
1314
"next": "15.1.7",
1415
"next-i18next": "^15.4.2",

src/app/layout.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ReactNode, useEffect, useState } from "react";
44
import "./globals.css";
55
import NavBar from "@/components/NavBar/NavBar";
66
import "@/i18n";
7+
import { fetchMe } from "@/lib/api/user";
78

89
export default function RootLayout({ children }: { children: ReactNode }) {
910
const [isLoggedIn, setIsLoggedIn] = useState<boolean | null>(null);
@@ -18,22 +19,15 @@ export default function RootLayout({ children }: { children: ReactNode }) {
1819

1920
async function checkAuth() {
2021
try {
21-
const res = await fetch("https://newara.dev.sparcs.org/api/me", {
22-
credentials: "include",
23-
});
24-
if (!res.ok) throw new Error("Not authenticated");
22+
await fetchMe();
2523
setIsLoggedIn(true);
2624
} catch {
27-
const handler = window.location.origin + "/auth-handler";
28-
const next = window.location.origin + "/";
29-
window.location.href =
30-
"https://newara.dev.sparcs.org/api/users/sso_login" +
31-
`?handler=${handler}&next=${next}`;
25+
console.error("인증 실패, 로그인 페이지로 리다이렉트합니다.");
26+
window.location.href = "/login";
3227
}
3328
}
3429

3530
checkAuth();
36-
// eslint-disable-next-line react-hooks/exhaustive-deps
3731
}, [pathname]);
3832

3933
// /login에서는 바로 children 렌더링

0 commit comments

Comments
 (0)