diff --git a/apps/web/pages/documents/[id]/index.tsx b/apps/web/pages/documents/[id]/index.tsx index 56e8e2989..c617258e4 100644 --- a/apps/web/pages/documents/[id]/index.tsx +++ b/apps/web/pages/documents/[id]/index.tsx @@ -131,6 +131,12 @@ export async function getServerSideProps(context: any) { // todo optimize querys // todo no intersection groups + if (!document) { + return { + notFound: true, + }; + } + return { props: { document: document, diff --git a/packages/lib/query/getDocument.ts b/packages/lib/query/getDocument.ts index f922f4c28..d19555f62 100644 --- a/packages/lib/query/getDocument.ts +++ b/packages/lib/query/getDocument.ts @@ -12,7 +12,7 @@ export const getDocument = async ( if (!documentId) Promise.reject("No documentId"); if (!req || !res) Promise.reject("No res or req"); - const document: PrismaDocument = await prisma.document.findFirstOrThrow({ + const document: PrismaDocument = await prisma.document.findFirst({ where: { id: documentId, userId: user.id,