diff --git a/lib/client/middleware.ts b/lib/client/middleware.ts index 5cc6dae..d94647c 100644 --- a/lib/client/middleware.ts +++ b/lib/client/middleware.ts @@ -26,8 +26,7 @@ export const storyMiddleware = defineNuxtRouteMiddleware(async (to, from) => { export const storyEditMiddleware = defineNuxtRouteMiddleware(async (to, from) => { const { data: curU } = useAuth(); - const rtr = useRoute(); - const { data: storyInfo } = await useApiFetch<({ chapters: (IChapter & { text: string })[] } & IStory) | null>(`/story/${rtr.params.id}/full`); + const { data: storyInfo } = await useApiFetch<({ chapters: (IChapter & { text: string })[] } & IStory) | null>(`/story/${to.params.id}/full`); if (!storyInfo.value) show404(); if (curU.value?.user?._id !== (storyInfo.value?.author as IUser)._id && curU.value?.user?._id !== (storyInfo.value?.coAuthor as IUser)?._id) { return showError({ @@ -38,8 +37,7 @@ export const storyEditMiddleware = defineNuxtRouteMiddleware(async (to, from) => }); export const draftEditMiddleware = defineNuxtRouteMiddleware(async (to, from) => { const { data: curU } = useAuth(); - const rtr = useRoute(); - const { data: storyInfo } = await useApiFetch(`/draft/${rtr.params.id}`); + const { data: storyInfo } = await useApiFetch(`/draft/${to.params.id}`); if (!storyInfo.value) show404(); if (curU.value?.user?._id !== (storyInfo.value?.author as IUser)._id && curU.value?.user?._id !== (storyInfo.value?.coAuthor as IUser)?._id) { return showError({