From 497ac11f26eb95e381f1a23c837f3977e73f411f Mon Sep 17 00:00:00 2001 From: root Date: Mon, 29 Dec 2025 18:03:43 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=EC=97=AC=EB=B6=80?= =?UTF-8?q?=20=ED=99=95=EC=9D=B8=ED=95=98=EB=8A=94=20=EC=9A=94=EC=B2=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/ImgInputForm.client.tsx | 9 ++++++++- src/app/components/ImgInputForm.server.tsx | 10 +++++++--- src/lib/Auth.ts | 6 ++++++ src/utils/Login.ts | 12 ++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/lib/Auth.ts create mode 100644 src/utils/Login.ts diff --git a/src/app/components/ImgInputForm.client.tsx b/src/app/components/ImgInputForm.client.tsx index f31feb3..0ec88f8 100644 --- a/src/app/components/ImgInputForm.client.tsx +++ b/src/app/components/ImgInputForm.client.tsx @@ -1,9 +1,16 @@ 'use client' -import { useRef, useState } from "react" +import { useEffect, useRef, useState } from "react" +import { callServer } from "@/lib/Auth" +import { isLogin } from "@/utils/Login" const ImgInputForm_client = () => { + //페이지 오픈 시 로그인 여부 확인 + useEffect(() => { + isLogin + }) + const fileRef = useRef(null) const [fileName, setFileName] = useState('') diff --git a/src/app/components/ImgInputForm.server.tsx b/src/app/components/ImgInputForm.server.tsx index 16cc65c..639473e 100644 --- a/src/app/components/ImgInputForm.server.tsx +++ b/src/app/components/ImgInputForm.server.tsx @@ -1,9 +1,13 @@ +'useClient' -import { cookies } from "next/headers" +import axios from "axios" const ImgInputForm_server = () => { - console.log('cookies :: ' + cookies.name) - return null + } +export const isLogin = axios.create({ + +}) + export default ImgInputForm_server \ No newline at end of file diff --git a/src/lib/Auth.ts b/src/lib/Auth.ts new file mode 100644 index 0000000..382576b --- /dev/null +++ b/src/lib/Auth.ts @@ -0,0 +1,6 @@ +import axios from "axios"; + +export const callServer = axios.create({ + baseURL: process.env.NEXT_PUBLIC_API_URL, + withCredentials: true +}) \ No newline at end of file diff --git a/src/utils/Login.ts b/src/utils/Login.ts new file mode 100644 index 0000000..8f6acdb --- /dev/null +++ b/src/utils/Login.ts @@ -0,0 +1,12 @@ +import { callServer } from "@/lib/Auth"; +import { redirect } from "next/navigation"; + +export async function isLogin() { + const res = callServer.get('/login/get-user-info').then(res => { + const userInfo = res.data + console.log(userInfo) + if (!userInfo) { + redirect('/login') + } + }) +} \ No newline at end of file