
250522 하석형 라우터 없는 페이지 notFound로 유도 처리 방식 변경, 콘텐츠유형관리 /cmmn/notFound.page 등록 불가 처리
@4f50e98993b6fd2fd5dc7e42253b06232d6ebff0
--- client/views/pages/AppRouter.js
+++ client/views/pages/AppRouter.js
... | ... | @@ -7,10 +7,13 @@ |
7 | 7 |
// 관리자 |
8 | 8 |
import CommonSelectList from "./adm/boardManagement/template/commonTemplate/CommonSelectList.vue"; |
9 | 9 |
import CommonSelectListOne from "./adm/boardManagement/template/commonTemplate/CommonSelectListOne.vue"; |
10 |
+// NotFound |
|
11 |
+import NotFound from "./user/etc/NotFound.vue"; |
|
10 | 12 |
|
11 | 13 |
const beforeRoutes = [ |
12 | 14 |
/* 메인화면 */ |
13 | 15 |
{ path: "/", name: "main", korName: "홈", component: Main }, |
16 |
+ { path: '/:pathMatch(.*)*', name: "PageNotFound", component: NotFound }, |
|
14 | 17 |
|
15 | 18 |
// 관리자 |
16 | 19 |
{ |
... | ... | @@ -166,9 +169,14 @@ |
166 | 169 |
|
167 | 170 |
AppRouter.beforeEach(async (to, from, next) => { |
168 | 171 |
const contextPath = store.state.contextPath; // Context Path 정보 |
169 |
- const routeExists = AppRouter.getRoutes().some(route => route.path === to.path || (route.name && route.name === to.name)); |
|
170 |
- if (!routeExists) { |
|
171 |
- next({ name: 'notfound' }); |
|
172 |
+ // const routeExists = AppRouter.getRoutes().some(route => route.path === to.path || (route.name && route.name === to.name)); |
|
173 |
+ // if (!routeExists) { |
|
174 |
+ // next({ name: 'notfound' }); |
|
175 |
+ // return; |
|
176 |
+ // } |
|
177 |
+ // vue3 권장방식 ('/:pathMatch(.*)*'로 라우터 유무 확인) |
|
178 |
+ if(to.name === 'PageNotFound') { |
|
179 |
+ next(); |
|
172 | 180 |
return; |
173 | 181 |
} |
174 | 182 |
|
--- client/views/pages/adm/preferences/contentTypeManagement/ContentTypeManagementInsert.vue
+++ client/views/pages/adm/preferences/contentTypeManagement/ContentTypeManagementInsert.vue
... | ... | @@ -222,9 +222,15 @@ |
222 | 222 |
this.contsTypeVO.pageCrs = pageCrs; |
223 | 223 |
|
224 | 224 |
const pageCrsRegex = /^\/(?:[a-zA-Z0-9_\-]+\/)*[a-zA-Z0-9_\-]+\.[a-zA-Z0-9]+$/; |
225 |
+ const notFound = '/cmmn/notfound.page'; |
|
225 | 226 |
if (!this.isEmpty(mngrPageCrs)) { |
226 | 227 |
if (!pageCrsRegex.test(this.contsTypeVO.mngrPageCrs)) { |
227 | 228 |
alert("관리자 PATH는 /로 시작하고, 마지막에 확장자가 포함되어야 합니다."); |
229 |
+ this.$refs.mngrPageCrs.focus(); |
|
230 |
+ return false; |
|
231 |
+ } |
|
232 |
+ if(this.contsTypeVO.mngrPageCrs.toLowerCase() == notFound) { |
|
233 |
+ alert("사용할 수 없는 경로입니다."); |
|
228 | 234 |
this.$refs.mngrPageCrs.focus(); |
229 | 235 |
return false; |
230 | 236 |
} |
... | ... | @@ -235,6 +241,11 @@ |
235 | 241 |
this.$refs.pageCrs.focus(); |
236 | 242 |
return false; |
237 | 243 |
} |
244 |
+ if(this.contsTypeVO.pageCrs.toLowerCase() == notFound) { |
|
245 |
+ alert("사용할 수 없는 경로입니다."); |
|
246 |
+ this.$refs.pageCrs.focus(); |
|
247 |
+ return false; |
|
248 |
+ } |
|
238 | 249 |
} |
239 | 250 |
|
240 | 251 |
// COMPONENT_URL |
--- server/modules/web/server.js
+++ server/modules/web/server.js
... | ... | @@ -147,6 +147,15 @@ |
147 | 147 |
|
148 | 148 |
/** |
149 | 149 |
* @author : 하석형 |
150 |
+ * @since : 2025.05.22 |
|
151 |
+ * @dscription : 404 Not Found 처리 |
|
152 |
+ */ |
|
153 |
+webServer.use(function(req, res, next) { |
|
154 |
+ res.status(404).redirect('/cmmn/notFound.page'); |
|
155 |
+}); |
|
156 |
+ |
|
157 |
+/** |
|
158 |
+ * @author : 하석형 |
|
150 | 159 |
* @since : 2023.08.24 |
151 | 160 |
* @dscription : Global Error Handler (*맨 마지막에 적용해야됨) |
152 | 161 |
*/ |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?