refactor: 에러 처리 완료, 페이지 접근 api 미들웨어로 수정
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
export default defineNuxtRouteMiddleware(async to => {
|
||||
try {
|
||||
//error 발생시에는 미들웨어 실행하지 않음
|
||||
//error 객체 조회
|
||||
if (import.meta.client) {
|
||||
|
||||
const error = useError()
|
||||
if(error.value?.statusCode){
|
||||
return showError(createError({
|
||||
statusCode: error.value?.statusCode,
|
||||
statusMessage: error.value?.message,
|
||||
fatal: true,
|
||||
// data: { path: to.path }
|
||||
}))
|
||||
}
|
||||
|
||||
const gameDataStore = useGameDataStore()
|
||||
const { gameData } = storeToRefs(gameDataStore)
|
||||
console.log('🚀 ~ 00000 gameData:', gameData.value)
|
||||
@@ -40,6 +53,7 @@ export default defineNuxtRouteMiddleware(async to => {
|
||||
!to.path.includes('inspection') &&
|
||||
!to.path.includes('api')
|
||||
) {
|
||||
console.log('e111111111 eee')
|
||||
// 점검 중인 경우
|
||||
return navigateTo(`/${finalLocale}/inspection`, { external: true })
|
||||
} else if (
|
||||
@@ -47,8 +61,11 @@ export default defineNuxtRouteMiddleware(async to => {
|
||||
to.path?.indexOf('inspection') !== -1
|
||||
) {
|
||||
// 점검이 종료된 후 점검 페이지 접근시 메인으로 리다이렉트
|
||||
console.log('ddddd 222222')
|
||||
return navigateTo(`/${finalLocale}`, { external: true })
|
||||
}
|
||||
|
||||
console.log('33333333 eee')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[Exception] /middleware/inspection: ', e)
|
||||
|
||||
Reference in New Issue
Block a user