diff --git a/apps/sn/app/page.tsx b/apps/sn/app/page.tsx
index d19bd5e79..9bfdbb656 100644
--- a/apps/sn/app/page.tsx
+++ b/apps/sn/app/page.tsx
@@ -1,50 +1,29 @@
-import { Button } from "@common/components";
-import Link from "next/link";
-import { redirect } from "next/navigation";
+"use client";
+import { LoginApi } from "@/entities/auth";
+import { useEffect } from "react";
+import { getCookie } from "@/shared/lib";
+import { AUTH_USER_ID } from "@/shared/config";
+import { useRouter } from "next/navigation";
export default function Home() {
- redirect("/map");
+ const router = useRouter();
+ const userId = "admin1gmail";
+ const password = "test1234!";
+ const checkToken = getCookie(AUTH_USER_ID);
- // return (
- //
- //
- //
하수관망도
- //
- //
- //
- //
- //
- //
- //
- //
운영정보 관리
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- // I/I 분석(기초정보 설정)
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- // );
+ useEffect(() => {
+ if (!checkToken) {
+ async function doLogin() {
+ try {
+ await LoginApi.login({ userId, password });
+ window.location.href = "/map";
+ } catch (err) {
+ console.error("로그인 실패", err);
+ }
+ }
+ doLogin();
+ } else {
+ router.push("/map");
+ }
+ }, []);
}
diff --git a/apps/sn/package.json b/apps/sn/package.json
index 95ec8f3e9..85e600dbb 100644
--- a/apps/sn/package.json
+++ b/apps/sn/package.json
@@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev -p 3002",
"build": "next build",
- "start": "next start",
+ "start": "next start -p 3002",
"lint": "next lint"
},
"dependencies": {
@@ -18,7 +18,6 @@
"@radix-ui/react-label": "^2.1.2",
"@radix-ui/react-slot": "^1.1.2",
"@tanstack/react-query": "^5.67.1",
- "@tanstack/react-query-devtools": "^5.75.5",
"@tanstack/react-table": "^8.21.2",
"axios": "^1.8.1",
"chart.js": "^4.4.8",
diff --git a/apps/sn/src/entities/auth/lib/auth-wrapper.tsx b/apps/sn/src/entities/auth/lib/auth-wrapper.tsx
index 4c4ce3645..f0710e249 100644
--- a/apps/sn/src/entities/auth/lib/auth-wrapper.tsx
+++ b/apps/sn/src/entities/auth/lib/auth-wrapper.tsx
@@ -7,9 +7,7 @@ import type { IUserInfo } from "@/shared/store";
import { useUserStore } from "@/shared/lib";
import { ENDPOINT, AUTH_USER_ID } from "@/shared/config";
import { getCookie } from "@/shared/lib";
-import axios from "axios";
import { LoginApi } from "../api/login-service";
-import { tokenManager } from "../lib/token-manager";
const CLAIM_NAME = process.env.NEXT_PUBLIC_CLAIM_NAME || "Authorization";
@@ -18,32 +16,14 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
const { userInfo, setUserInfo } = useUserStore((state) => state);
async function authCheck() {
- const checkToken = getCookie(AUTH_USER_ID);
-
-
- if (!checkToken) {
- //TODO 나중에 수정해야....
- const userId = "admin1gmail";
- const password = "test1234!";
- await LoginApi.login({ userId, password });
- // window.location.href = "http://dev.onasys.co.kr/auth/login";
- // throw new Error("Missing required authentication tokens");
+ const userId = getCookie(AUTH_USER_ID);
+ if (!userId) {
+ throw new Error("Missing required authentication tokens");
}
- const accessToken = tokenManager.getToken(CLAIM_NAME);
- const tokenId = tokenManager.getToken(AUTH_USER_ID);
-
- const response = await axios.get(
+ const response = await client.get(
`${ENDPOINT.USER_SERVICE.USERS}/info/me`,
- {
- withCredentials: true,
- headers: {
- [CLAIM_NAME]: accessToken,
- [AUTH_USER_ID]: tokenId ?? "",
- },
- },
);
-
if (!userInfo) setUserInfo(response.data);
}
@@ -60,12 +40,7 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
} catch (refreshError) {
console.error("Token refresh failed:", refreshError);
setUserInfo(null);
-
- // TODO 운영에 반영 할때 수정해야.....
- // 현재 경로가 로그인 페이지가 아닐 때만 redirect
- // if (!pathname.startsWith("/auth/login")) {
- // window.location.href = "http://dev.onasys.co.kr/auth/login";
- // }
+ router.push("/");
}
}
})();