diff --git a/packages/next/src/views/Document/index.tsx b/packages/next/src/views/Document/index.tsx index 0f49023a18..cb5c03a39f 100644 --- a/packages/next/src/views/Document/index.tsx +++ b/packages/next/src/views/Document/index.tsx @@ -75,6 +75,10 @@ export const Document: React.FC = async ({ req, }) + if (!data) { + notFound() + } + const { docPermissions, hasPublishPermission, hasSavePermission } = await getDocumentPermissions({ id, collectionConfig, diff --git a/test/admin/e2e/1/e2e.spec.ts b/test/admin/e2e/1/e2e.spec.ts index ac3b382c58..36dd88c559 100644 --- a/test/admin/e2e/1/e2e.spec.ts +++ b/test/admin/e2e/1/e2e.spec.ts @@ -336,6 +336,20 @@ describe('admin1', () => { }) describe('routing', () => { + test('should 404 not found root pages', async () => { + await page.goto(`${serverURL}/admin/1234`) + const response = await page.waitForResponse((response) => response.status() === 404) + expect(response).toBeTruthy() + await expect(page.locator('.not-found')).toContainText('Nothing found') + }) + + test('should 404 not found documents', async () => { + await page.goto(`${postsUrl.collection(postsCollectionSlug)}/1234`) + const response = await page.waitForResponse((response) => response.status() === 404) + expect(response).toBeTruthy() + await expect(page.locator('.not-found')).toContainText('Nothing found') + }) + test('should use custom logout route', async () => { await page.goto(`${serverURL}${adminRoutes.routes.admin}${adminRoutes.admin.routes.logout}`) diff --git a/tsconfig.json b/tsconfig.json index ae27597fb0..fdef1fc52c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,7 +37,7 @@ ], "paths": { "@payload-config": [ - "./test/_community/config.ts" + "./test/admin/config.ts" ], "@payloadcms/live-preview": [ "./packages/live-preview/src"