Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Fix deleted website visibility bug Closes #3865

Francis Cao912d2d544dac
diff --git a/src/app/(main)/links/[linkId]/page.tsx b/src/app/(main)/links/[linkId]/page.tsx
index 4317ada23..3a5f5d7ee 100644
--- a/src/app/(main)/links/[linkId]/page.tsx
+++ b/src/app/(main)/links/[linkId]/page.tsx
@@ -1,8 +1,14 @@
import type { Metadata } from 'next';
+import { getLink } from '@/queries/prisma';
import { LinkPage } from './LinkPage';
export default async function ({ params }: { params: Promise<{ linkId: string }> }) {
const { linkId } = await params;
+ const link = await getLink(linkId);
+
+ if (!link || link?.deletedAt) {
+ return null;
+ }
return <LinkPage linkId={linkId} />;
}
diff --git a/src/app/(main)/pixels/[pixelId]/page.tsx b/src/app/(main)/pixels/[pixelId]/page.tsx
index d1db92f3d..e174c195c 100644
--- a/src/app/(main)/pixels/[pixelId]/page.tsx
+++ b/src/app/(main)/pixels/[pixelId]/page.tsx
@@ -1,8 +1,14 @@
import type { Metadata } from 'next';
+import { getPixel } from '@/queries/prisma';
import { PixelPage } from './PixelPage';
export default async function ({ params }: { params: { pixelId: string } }) {
const { pixelId } = await params;
+ const pixel = await getPixel(pixelId);
+
+ if (!pixel || pixel?.deletedAt) {
+ return null;
+ }
return <PixelPage pixelId={pixelId} />;
}
diff --git a/src/app/(main)/websites/[websiteId]/layout.tsx b/src/app/(main)/websites/[websiteId]/layout.tsx
index 67595e9d1..b12ff9505 100644
--- a/src/app/(main)/websites/[websiteId]/layout.tsx
+++ b/src/app/(main)/websites/[websiteId]/layout.tsx
@@ -1,5 +1,6 @@
import type { Metadata } from 'next';
import { WebsiteLayout } from '@/app/(main)/websites/[websiteId]/WebsiteLayout';
+import { getWebsite } from '@/queries/prisma';
export default async function ({
children,
@@ -9,6 +10,11 @@ export default async function ({
params: Promise<{ websiteId: string }>;
}) {
const { websiteId } = await params;
+ const website = await getWebsite(websiteId);
+
+ if (!website || website?.deletedAt) {
+ return null;
+ }
return <WebsiteLayout websiteId={websiteId}>{children}</WebsiteLayout>;
}
diff --git a/src/lib/request.ts b/src/lib/request.ts
index e6450bf31..d6543b184 100644
--- a/src/lib/request.ts
+++ b/src/lib/request.ts
@@ -85,7 +85,7 @@ export async function setWebsiteDate(websiteId: string, userId: string, data: Re
const website = await fetchWebsite(websiteId);
const cloudMode = !!process.env.CLOUD_MODE;
- if (cloudMode && !website.teamId) {
+ if (cloudMode && website && !website.teamId) {
const account = await fetchAccount(userId);
if (!account?.hasSubscription) {