From e846b55faafbd0151c88256bf1f321ade5aa3c63 Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Thu, 22 May 2025 15:00:41 +0900 Subject: [PATCH 1/5] chore: Update environment configuration and enhance API integration - Added NEXT_PUBLIC_RUN_MODE to .env files for environment differentiation. - Introduced .env.localhost for local development settings. - Updated .env.production with the correct API URL. - Modified package.json scripts to utilize env-cmd for environment-specific commands. - Created a common configuration module to manage environment-specific settings. - Refactored useAxios to utilize the new configuration for base URL management. - Enhanced Footer component to display current configuration values. --- .env.development | 1 + .env.localhost | 18 +++++++++ .env.production | 3 +- package.json | 7 +++- pnpm-lock.yaml | 63 +++++++++++++++++++++++++++++ src/components/Login.tsx | 5 ++- src/components/ui/common/Footer.tsx | 4 ++ src/config/config.common.ts | 20 +++++++++ src/config/config.development.ts | 13 ++++++ src/config/config.export.ts | 19 +++++++++ src/config/config.local.ts | 13 ++++++ src/config/config.production.ts | 13 ++++++ src/hooks/useAxios.ts | 3 +- 13 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 .env.localhost create mode 100644 src/config/config.common.ts create mode 100644 src/config/config.development.ts create mode 100644 src/config/config.export.ts create mode 100644 src/config/config.local.ts create mode 100644 src/config/config.production.ts diff --git a/.env.development b/.env.development index 1a372fa..47cfa78 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,4 @@ +NEXT_PUBLIC_RUN_MODE=development # 모바일 디바이스로 로컬 서버 확인하려면 자신 IP 주소로 변경 # 다시 로컬에서 개발할때는 localhost로 변경 #route handler diff --git a/.env.localhost b/.env.localhost new file mode 100644 index 0000000..966e366 --- /dev/null +++ b/.env.localhost @@ -0,0 +1,18 @@ +NEXT_PUBLIC_RUN_MODE=local +# 모바일 디바이스로 로컬 서버 확인하려면 자신 IP 주소로 변경 +# 다시 로컬에서 개발할때는 localhost로 변경 +#route handler +NEXT_PUBLIC_API_URL=http://localhost:3000 + +#qsp 로그인 api +NEXT_PUBLIC_QSP_API_URL=http://1.248.227.176:8120 + +#1:1문의 api +NEXT_PUBLIC_INQUIRY_API_URL=http://1.248.227.176:38080 + +#QPARTNER 로그인 api +DB_HOST=202.218.61.226 +DB_USER=readonly +DB_PASSWORD=aAjmFW12iHKW84l1 +DB_DATABASE=qpartners +DB_PORT=3306 \ No newline at end of file diff --git a/.env.production b/.env.production index 4c39e83..ce56225 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,6 @@ +NEXT_PUBLIC_RUN_MODE=production #route handler -NEXT_PUBLIC_API_URL=http://172.30.1.35:3000 +NEXT_PUBLIC_API_URL=http://1.248.227.176:3000 #qsp 로그인 api NEXT_PUBLIC_QSP_API_URL=http://1.248.227.176:8120 diff --git a/package.json b/package.json index a57feca..d3be4d7 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,13 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev --turbopack", + "dev": "env-cmd -f .env.localhost next dev --turbopack", "build": "next build", "start": "next start", + "build:dev": "env-cmd -f .env.development next build", + "build:prod": "env-cmd -f .env.production next build", + "start:dev": "env-cmd -f .env.development next start", + "start:prod": "env-cmd -f .env.production next start", "lint": "next lint" }, "dependencies": { @@ -13,6 +17,7 @@ "@tanstack/react-query": "^5.71.0", "@tanstack/react-query-devtools": "^5.71.0", "axios": "^1.8.4", + "env-cmd": "^10.1.0", "iron-session": "^8.0.4", "lucide": "^0.503.0", "mssql": "^11.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d972d8..ee300e7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: axios: specifier: ^1.8.4 version: 1.8.4 + env-cmd: + specifier: ^10.1.0 + version: 10.1.0 iron-session: specifier: ^8.0.4 version: 8.0.4 @@ -801,6 +804,10 @@ packages: resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} engines: {node: '>=16'} + commander@4.1.1: + resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} + engines: {node: '>= 6'} + cookie@0.7.2: resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} engines: {node: '>= 0.6'} @@ -808,6 +815,10 @@ packages: core-js@3.41.0: resolution: {integrity: sha512-SJ4/EHwS36QMJd6h/Rg+GyR4A5xE0FSI3eZ+iBVpfqf1x0eTSg1smWLHrA+2jQThZSh97fmSgFSU8B61nxosxA==} + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} + engines: {node: '>= 8'} + css-line-break@2.1.0: resolution: {integrity: sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==} @@ -866,6 +877,11 @@ packages: resolution: {integrity: sha512-ZSW3ma5GkcQBIpwZTSRAI8N71Uuwgs93IezB7mf7R60tC8ZbJideoDNKjHn2O9KIlx6rkGTTEk1xUCK2E1Y2Yg==} engines: {node: '>=10.13.0'} + env-cmd@10.1.0: + resolution: {integrity: sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==} + engines: {node: '>=8.0.0'} + hasBin: true + es-define-property@1.0.1: resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} engines: {node: '>= 0.4'} @@ -1021,6 +1037,9 @@ packages: resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==} engines: {node: '>=16'} + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + jiti@2.4.2: resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==} hasBin: true @@ -1217,6 +1236,10 @@ packages: resolution: {integrity: sha512-mnkeQ1qP5Ue2wd+aivTD3NHd/lZ96Lu0jgf0pwktLPtx6cTZiH7tyeGRRHs0zX0rbrahXPnXlUnbeXyaBBuIaw==} engines: {node: '>=18'} + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + performance-now@2.1.0: resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} @@ -1324,6 +1347,14 @@ packages: resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + simple-swizzle@0.2.2: resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} @@ -1423,6 +1454,11 @@ packages: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + zustand@5.0.3: resolution: {integrity: sha512-14fwWQtU3pH4dE0dOpdMiWjddcH+QzKIgk1cl8epwSE7yag43k/AD/m4L6+K7DytAOr9gGBe3/EXj9g7cdostg==} engines: {node: '>=12.20.0'} @@ -2070,11 +2106,19 @@ snapshots: commander@11.1.0: {} + commander@4.1.1: {} + cookie@0.7.2: {} core-js@3.41.0: optional: true + cross-spawn@7.0.6: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + css-line-break@2.1.0: dependencies: utrie: 1.0.2 @@ -2123,6 +2167,11 @@ snapshots: graceful-fs: 4.2.11 tapable: 2.2.1 + env-cmd@10.1.0: + dependencies: + commander: 4.1.1 + cross-spawn: 7.0.6 + es-define-property@1.0.1: {} es-errors@1.3.0: {} @@ -2297,6 +2346,8 @@ snapshots: dependencies: is-inside-container: 1.0.0 + isexe@2.0.0: {} + jiti@2.4.2: {} js-md4@0.3.2: {} @@ -2500,6 +2551,8 @@ snapshots: is-inside-container: 1.0.0 is-wsl: 3.1.0 + path-key@3.1.1: {} + performance-now@2.1.0: optional: true @@ -2622,6 +2675,12 @@ snapshots: '@img/sharp-win32-x64': 0.33.5 optional: true + shebang-command@2.0.0: + dependencies: + shebang-regex: 3.0.0 + + shebang-regex@3.0.0: {} + simple-swizzle@0.2.2: dependencies: is-arrayish: 0.3.2 @@ -2703,6 +2762,10 @@ snapshots: uuid@8.3.2: {} + which@2.0.2: + dependencies: + isexe: 2.0.0 + zustand@5.0.3(@types/react@19.0.12)(react@19.1.0): optionalDependencies: '@types/react': 19.0.12 diff --git a/src/components/Login.tsx b/src/components/Login.tsx index 6322ec4..043fee6 100644 --- a/src/components/Login.tsx +++ b/src/components/Login.tsx @@ -5,9 +5,8 @@ import { useEffect, useReducer, useState } from 'react' import { useRouter } from 'next/navigation' import { useLocalStorage } from 'usehooks-ts' import { useQuery } from '@tanstack/react-query' -import { axiosInstance } from '@/libs/axios' import { useSessionStore } from '@/store/session' - +import { useAxios } from '@/hooks/useAxios' interface AccountState { loginId: string pwd: string @@ -24,6 +23,8 @@ export default function Login() { //로그인 상태 const [isLogin, setIsLogin] = useState(false) + const { axiosInstance } = useAxios() + const { session, setSession } = useSessionStore() const [value, setValue, removeValue] = useLocalStorage<{ indivisualData: string }>('hanasysIndivisualState', { indivisualData: '' }) diff --git a/src/components/ui/common/Footer.tsx b/src/components/ui/common/Footer.tsx index 08cce69..2d20a63 100644 --- a/src/components/ui/common/Footer.tsx +++ b/src/components/ui/common/Footer.tsx @@ -1,6 +1,7 @@ 'use client' import Link from 'next/link' +import Config from '@/config/config.export' export default function Footer() { return ( @@ -11,6 +12,9 @@ export default function Footer() { PDF + {Config().mode} + {Config().baseUrl} + {process.env.NEXT_PUBLIC_API_URL} diff --git a/src/config/config.common.ts b/src/config/config.common.ts new file mode 100644 index 0000000..e99d9f0 --- /dev/null +++ b/src/config/config.common.ts @@ -0,0 +1,20 @@ +export declare namespace ICommonConfig { + export type Mode = 'local' | 'development' | 'production' + + export interface Params { + baseUrl: string + mode: Mode + } +} + +// local, development, production 과 관계없이 동일한 값으로 반환되는 부분은 해당 함수의 return 되는 부분만 수정하면 됩니다. (달라져야 하는 값이 아닌, 같은 값에 대해서는 local, development, production 파일을 모두 수정할 필요가 없어지게 됩니다.) +export default function getConfigs(params: ICommonConfig.Params) { + // local, development, production 마다 달라지는 값 + const { baseUrl, mode } = params + + // 공통으로 반환되는 구조 + return { + baseUrl, + mode, + } +} diff --git a/src/config/config.development.ts b/src/config/config.development.ts new file mode 100644 index 0000000..70765ec --- /dev/null +++ b/src/config/config.development.ts @@ -0,0 +1,13 @@ +import getConfigs from '@/config/config.common' + +// 환경마다 달라져야 할 변수, 값들을 정의합니다. (여기는 development 환경에 맞는 값을 지정합니다.) +const baseUrl = 'http://1.248.227.176:3000' +const mode = 'development' + +// 환경마다 달라져야 할 값들을 getConfig 함수에 전달합니다. +const configDevelopment = getConfigs({ + baseUrl, + mode, +}) + +export default configDevelopment diff --git a/src/config/config.export.ts b/src/config/config.export.ts new file mode 100644 index 0000000..8948763 --- /dev/null +++ b/src/config/config.export.ts @@ -0,0 +1,19 @@ +import configDevelopment from './config.development' +import configLocal from './config.local' +import configProduction from './config.production' + +// 클라이언트에서는 이 함수를 사용하여 config 값을 참조합니다. +const Config = () => { + switch (process.env.NEXT_PUBLIC_RUN_MODE) { + case 'local': + return configLocal + case 'development': + return configDevelopment + case 'production': + return configProduction + default: + return configLocal + } +} + +export default Config diff --git a/src/config/config.local.ts b/src/config/config.local.ts new file mode 100644 index 0000000..ac02c97 --- /dev/null +++ b/src/config/config.local.ts @@ -0,0 +1,13 @@ +import getConfigs from '@/config/config.common' + +// 환경마다 달라져야 할 변수, 값들을 정의합니다. (여기는 local 환경에 맞는 값을 지정합니다.) +const baseUrl = 'http://localhost:3000' +const mode = 'local' + +// 환경마다 달라져야 할 값들을 getConfig 함수에 전달합니다. +const configLocal = getConfigs({ + baseUrl, + mode, +}) + +export default configLocal diff --git a/src/config/config.production.ts b/src/config/config.production.ts new file mode 100644 index 0000000..5b1db52 --- /dev/null +++ b/src/config/config.production.ts @@ -0,0 +1,13 @@ +import getConfigs from '@/config/config.common' + +// 환경마다 달라져야 할 변수, 값들을 정의합니다. (여기는 production 환경에 맞는 값을 지정합니다.) +const baseUrl = 'http://localhost.prod:3000' +const mode = 'production' + +// 환경마다 달라져야 할 값들을 getConfig 함수에 전달합니다. +const configProduction = getConfigs({ + baseUrl, + mode, +}) + +export default configProduction diff --git a/src/hooks/useAxios.ts b/src/hooks/useAxios.ts index ac59166..49c5ec0 100644 --- a/src/hooks/useAxios.ts +++ b/src/hooks/useAxios.ts @@ -1,11 +1,12 @@ import axios from 'axios' +import Config from '@/config/config.export' import { useSpinnerStore } from '@/store/spinnerStore' export const useAxios = () => { const { setIsShow } = useSpinnerStore() const axiosInstance = (url: string | null | undefined) => { - const baseURL = url || process.env.NEXT_PUBLIC_API_URL + const baseURL = url || Config().baseUrl const instance = axios.create({ baseURL, headers: { From 0a88c80bd9f8a43449ab1e25327b99afeaa1f900 Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Thu, 22 May 2025 15:04:59 +0900 Subject: [PATCH 2/5] refactor: Update Header component to utilize useAxios for API integration - Replaced direct axiosInstance import with useAxios hook for improved API management. - Cleaned up imports and enhanced code structure for better readability. --- src/components/ui/common/Header.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/ui/common/Header.tsx b/src/components/ui/common/Header.tsx index bd92675..734f58f 100644 --- a/src/components/ui/common/Header.tsx +++ b/src/components/ui/common/Header.tsx @@ -13,14 +13,13 @@ import { useSessionStore } from '@/store/session' import { usePopupController } from '@/store/popupController' import { useTitle } from '@/hooks/useTitle' - -import { axiosInstance } from '@/libs/axios' - +import { useAxios } from '@/hooks/useAxios' import 'swiper/css' export default function Header() { const router = useRouter() const pathname = usePathname() + const { axiosInstance } = useAxios() const [value, setValue, removeValue] = useLocalStorage<{ indivisualData: string }>('hanasysIndivisualState', { indivisualData: '' }) const { sideNavIsOpen, setSideNavIsOpen } = useSideNavState() const { backBtn } = useHeaderStore() From e8498948df7bd4b50d3a32f76560d460876b2764 Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Thu, 22 May 2025 15:07:41 +0900 Subject: [PATCH 3/5] refactor: Update tracking function to utilize useAxios for API calls - Replaced direct axiosInstance import with useAxios hook for improved API management. - Enhanced code structure for better readability and maintainability. --- src/libs/tracking.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/tracking.ts b/src/libs/tracking.ts index 2f8833f..f06a3e7 100644 --- a/src/libs/tracking.ts +++ b/src/libs/tracking.ts @@ -1,7 +1,8 @@ -import { axiosInstance } from './axios' +import { useAxios } from '@/hooks/useAxios' export const tracking = async (params: { url: string; data: string }) => { const { url, data } = params + const { axiosInstance } = useAxios() const result = await axiosInstance(null).post('/api/tracking', { url, data, From c76526bf9bc9d59d3a8d6aaeb28648ee2a84c47c Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Thu, 22 May 2025 16:57:54 +0900 Subject: [PATCH 4/5] chore: Update package.json scripts and enhance middleware session handling - Added local build and start scripts to package.json for improved local development. - Commented out login redirection logic in middleware for future implementation. - Introduced a new checkbox in the sample page for enhanced UI functionality. - Refactored useAxios to improve request and response handling with better modularization. - Updated checkbox styles in SCSS for improved visual consistency. --- package.json | 2 + src/app/sample/page.tsx | 4 ++ src/hooks/useAxios.ts | 69 +++++++++++++++++++++---------- src/middleware.ts | 6 +-- src/styles/base/_check-radio.scss | 17 ++++++++ 5 files changed, 73 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index d3be4d7..53ed0e8 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,10 @@ "dev": "env-cmd -f .env.localhost next dev --turbopack", "build": "next build", "start": "next start", + "build:local": "env-cmd -f .env.localhost next build", "build:dev": "env-cmd -f .env.development next build", "build:prod": "env-cmd -f .env.production next build", + "start:local": "env-cmd -f .env.localhost next start", "start:dev": "env-cmd -f .env.development next start", "start:prod": "env-cmd -f .env.production next start", "lint": "next lint" diff --git a/src/app/sample/page.tsx b/src/app/sample/page.tsx index c4c30d3..1ae671d 100644 --- a/src/app/sample/page.tsx +++ b/src/app/sample/page.tsx @@ -113,6 +113,10 @@ export default function page() { +
+ + +
diff --git a/src/hooks/useAxios.ts b/src/hooks/useAxios.ts index 49c5ec0..3fc9e4e 100644 --- a/src/hooks/useAxios.ts +++ b/src/hooks/useAxios.ts @@ -1,40 +1,65 @@ -import axios from 'axios' +import axios, { AxiosResponse, InternalAxiosRequestConfig } from 'axios' import Config from '@/config/config.export' import { useSpinnerStore } from '@/store/spinnerStore' -export const useAxios = () => { - const { setIsShow } = useSpinnerStore() +export function useAxios() { + // const { setIsShow } = useSpinnerStore() + + const requestHandler = (config: InternalAxiosRequestConfig) => { + // setIsShow(true) + return config + } + + const responseHandler = (response: AxiosResponse) => { + // setIsShow(false) + response.data = transferResponse(response) + return response + } + + const errorHandler = (error: any) => { + // setIsShow(false) + return Promise.reject(error) + } + + const createAxiosInstance = (url: string | null | undefined) => { + const baseURL = url || Config().baseUrl + return axios.create({ + baseURL, + headers: { + Accept: 'application/json', + }, + }) + } const axiosInstance = (url: string | null | undefined) => { - const baseURL = url || Config().baseUrl const instance = axios.create({ - baseURL, + baseURL: url || Config().baseUrl, headers: { Accept: 'application/json', }, }) instance.interceptors.request.use( - (config) => { - // console.log('🚀 ~ config:', config) - setIsShow(true) - return config - }, - (error) => { - return Promise.reject(error) - }, + // (config) => { + // return config + // }, + // (error) => { + // return Promise.reject(error) + // }, + (config) => requestHandler(config), + (error) => errorHandler(error), ) instance.interceptors.response.use( - (response) => { - response.data = transferResponse(response) - setIsShow(false) - return response - }, - (error) => { - // 에러 처리 로직 - return Promise.reject(error) - }, + // (response) => { + // response.data = transferResponse(response) + // return response + // }, + // (error) => { + // return Promise.reject(error) + // }, + (response) => responseHandler(response), + (error) => errorHandler(error), ) return instance diff --git a/src/middleware.ts b/src/middleware.ts index 115fd8a..1bcfd96 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -10,9 +10,9 @@ export async function middleware(request: NextRequest) { const session = await getIronSession(cookieStore, sessionOptions) // todo: 로그인 기능 추가 시 주석 해제 - if (!session.isLoggedIn) { - return NextResponse.redirect(new URL('/login', request.url)) - } + // if (!session.isLoggedIn) { + // return NextResponse.redirect(new URL('/login', request.url)) + // } return NextResponse.next() } diff --git a/src/styles/base/_check-radio.scss b/src/styles/base/_check-radio.scss index f6ff573..fea97ff 100644 --- a/src/styles/base/_check-radio.scss +++ b/src/styles/base/_check-radio.scss @@ -98,6 +98,23 @@ color: #8595A7; } } + &.space{ + label{ + &::after{ + top: 8px; + left: 0px; + width: 10px; + height: 2px; + border: none; + background-color: transparent; + transform: translate(50%, 50%); + -ms-transform: none; + } + } + input[type="checkbox"]:checked + label::after{ + background-color: #fff; + } + } } // radio box From a5696984fc91f35c2847c1422da43246508f2c8a Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Thu, 22 May 2025 17:08:54 +0900 Subject: [PATCH 5/5] refactor: Update middleware and EdgeProvider for session handling - Modified middleware matcher to exclude additional routes for improved session management. - Added login redirection logic in EdgeProvider to ensure users are redirected to the login page if not authenticated. --- src/middleware.ts | 2 +- src/providers/EdgeProvider.tsx | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/middleware.ts b/src/middleware.ts index 1bcfd96..01d1334 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -22,5 +22,5 @@ export async function middleware(request: NextRequest) { // 2. /admin/* (exclude all routes under /admin) // 3. /_next/* (exclude Next.js static and image assets) export const config = { - matcher: ['/((?!dashboard|login|admin|api|_next/static|_next/image|favicon.ico).*)'], + matcher: ['/((?!login|assets).*)', '/((?!_next/static|_next/image|favicon.ico).*)'], } diff --git a/src/providers/EdgeProvider.tsx b/src/providers/EdgeProvider.tsx index e04f0e5..b53884f 100644 --- a/src/providers/EdgeProvider.tsx +++ b/src/providers/EdgeProvider.tsx @@ -74,6 +74,12 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp router.push('/') } } + + if (pathname === '/') { + if (!session?.isLoggedIn) { + router.push('/login') + } + } //alert 함수 변경해서 바인딩 window.alert = function (msg, alertBtn = () => setAlert(false)) { alertFunc(msg, alertBtn)