From e6a0a403191b8a6a1d309d3deeefc0c22957d94e Mon Sep 17 00:00:00 2001 From: Azri Kahar <42867097+azrikahar@users.noreply.github.com> Date: Tue, 1 Mar 2022 00:05:58 +0800 Subject: [PATCH] redirect to page not found for invalid collections (#11882) --- app/src/modules/settings/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/modules/settings/index.ts b/app/src/modules/settings/index.ts index 231c2c9ede..866215cf75 100644 --- a/app/src/modules/settings/index.ts +++ b/app/src/modules/settings/index.ts @@ -62,12 +62,19 @@ export default defineModule({ async beforeEnter(to) { const collectionsStore = useCollectionsStore(); const info = collectionsStore.getCollection(to.params.collection as string); - const fieldsStore = useFieldsStore(); + + if (!info) { + return { + name: 'settings-not-found', + params: { _: to.path.split('/').slice(1) }, + }; + } if (!info?.meta) { await api.patch(`/collections/${to.params.collection}`, { meta: {} }); } + const fieldsStore = useFieldsStore(); fieldsStore.hydrate(); }, props: (route) => ({