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.
This commit is contained in:
yoosangwook 2025-05-22 16:57:54 +09:00
parent e8498948df
commit c76526bf9b
5 changed files with 73 additions and 25 deletions

View File

@ -6,8 +6,10 @@
"dev": "env-cmd -f .env.localhost next dev --turbopack", "dev": "env-cmd -f .env.localhost next dev --turbopack",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"build:local": "env-cmd -f .env.localhost next build",
"build:dev": "env-cmd -f .env.development next build", "build:dev": "env-cmd -f .env.development next build",
"build:prod": "env-cmd -f .env.production 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:dev": "env-cmd -f .env.development next start",
"start:prod": "env-cmd -f .env.production next start", "start:prod": "env-cmd -f .env.production next start",
"lint": "next lint" "lint": "next lint"

View File

@ -113,6 +113,10 @@ export default function page() {
<input type="checkbox" id="ch06" disabled /> <input type="checkbox" id="ch06" disabled />
<label htmlFor="ch06">Check Box</label> <label htmlFor="ch06">Check Box</label>
</div> </div>
<div className="check-form-box space">
<input type="checkbox" id="ch07" defaultChecked />
<label htmlFor="ch07">Check Box</label>
</div>
</div> </div>
</div> </div>
<div className="design-box"> <div className="design-box">

View File

@ -1,40 +1,65 @@
import axios from 'axios' import axios, { AxiosResponse, InternalAxiosRequestConfig } from 'axios'
import Config from '@/config/config.export' import Config from '@/config/config.export'
import { useSpinnerStore } from '@/store/spinnerStore' import { useSpinnerStore } from '@/store/spinnerStore'
export const useAxios = () => { export function useAxios() {
const { setIsShow } = useSpinnerStore() // 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 axiosInstance = (url: string | null | undefined) => {
const baseURL = url || Config().baseUrl
const instance = axios.create({ const instance = axios.create({
baseURL, baseURL: url || Config().baseUrl,
headers: { headers: {
Accept: 'application/json', Accept: 'application/json',
}, },
}) })
instance.interceptors.request.use( instance.interceptors.request.use(
(config) => { // (config) => {
// console.log('🚀 ~ config:', config) // return config
setIsShow(true) // },
return config // (error) => {
}, // return Promise.reject(error)
(error) => { // },
return Promise.reject(error) (config) => requestHandler(config),
}, (error) => errorHandler(error),
) )
instance.interceptors.response.use( instance.interceptors.response.use(
(response) => { // (response) => {
response.data = transferResponse(response) // response.data = transferResponse(response)
setIsShow(false) // return response
return response // },
}, // (error) => {
(error) => { // return Promise.reject(error)
// 에러 처리 로직 // },
return Promise.reject(error) (response) => responseHandler(response),
}, (error) => errorHandler(error),
) )
return instance return instance

View File

@ -10,9 +10,9 @@ export async function middleware(request: NextRequest) {
const session = await getIronSession<SessionData>(cookieStore, sessionOptions) const session = await getIronSession<SessionData>(cookieStore, sessionOptions)
// todo: 로그인 기능 추가 시 주석 해제 // todo: 로그인 기능 추가 시 주석 해제
if (!session.isLoggedIn) { // if (!session.isLoggedIn) {
return NextResponse.redirect(new URL('/login', request.url)) // return NextResponse.redirect(new URL('/login', request.url))
} // }
return NextResponse.next() return NextResponse.next()
} }

View File

@ -98,6 +98,23 @@
color: #8595A7; 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 // radio box