-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathpage.tsx
More file actions
30 lines (25 loc) · 941 Bytes
/
page.tsx
File metadata and controls
30 lines (25 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { auth } from "@/auth";
import { redirect } from "next/navigation";
import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { prisma } from "@/prisma";
// @note: we were hitting `PrismaClientInitializationError` errors during
// build time. Next.js performs a static generation probe on all pages during
// `next build`, running each page component to determine if it's static or
// dynamic. `force-dynamic` skips the probe entirely so this page is always
// rendered at request time.
export const dynamic = 'force-dynamic';
export default async function Page() {
const org = await prisma.org.findUnique({
where: {
domain: SINGLE_TENANT_ORG_DOMAIN
}
});
if (!org || !org.isOnboarded) {
return redirect("/onboard");
}
const session = await auth();
if (!session) {
return redirect("/login");
}
return redirect(`/${SINGLE_TENANT_ORG_DOMAIN}`);
}