Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
Merge branch 'main' into feat/domains
Marc Seitz879a279dc307
diff --cc components/links/link-sheet/index.tsxindex f3d87b21,aa080a46..df66f10e--- a/components/links/link-sheet/index.tsx+++ b/components/links/link-sheet/index.tsx@@@ -16,10 -14,12 +14,13 @@@ import ExpirationSection from "./expiraimport EmailProtectionSection from "./email-protection-section";import { useRouter } from "next/router";import { useDocumentLinks } from "@/lib/swr/use-document";+import { useDomains } from "@/lib/swr/use-domains";import { mutate } from "swr";+ import { Button } from "@/components/ui/button";+ import { toast } from "sonner";- const DEFAULT_LINK_PROPS = {+ export const DEFAULT_LINK_PROPS = {+ id: null,name: null,expiresAt: null,password: null,diff --cc middleware.tsindex db38aab5,06dd74c2..2858c007--- a/middleware.ts+++ b/middleware.ts@@@ -18,20 -18,8 +18,20 @@@ export const config =export default async function middleware(req: NextRequest, ev: NextFetchEvent) {const path = req.nextUrl.pathname;+ const host = req.headers.get('host');+ const url = req.nextUrl.clone();++ if (+ process.env.NODE_ENV !== "development" &&+ !(host?.includes("papermark.io") || host?.endsWith(".vercel.app"))+ ) {+ // Subdomain available, rewriting+ console.log(`>>> Rewriting: ${path} to /view/domains/${host}${path}`);+ url.pathname = `/view/domains/${host}${path}`;+ return NextResponse.rewrite(url);+ }- if (path !== "/" && path !== "/alternatives/docsend") {+ if (path !== "/" && path !== "/alternatives/docsend" && !path.startsWith("/view/")) {return AppMiddleware(req);}diff --cc prisma/schema.prismaindex 715719a5,309a793d..8b67acb9--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@@ -82,30 -81,13 +83,31 @@@ model LinkexpiresAt DateTime? // Optional expiration datepassword String? // Optional password for link protectionallowedEmails String[] // Array of emails allowed to view the document- emailProtected Boolean? @default(true) // Optional email protection+ emailProtected Boolean @default(true) // Optional email protection+ isArchived Boolean @default(false) // Indicates if the link is archivedviews View[]+ domain Domain? @relation(fields: [domainId], references: [id], onDelete: SetNull)+ domainId String? // This can be nullable, representing links without custom domains+ domainSlug String? // This will store the domain's slug even if the domain is deletedcreatedAt DateTime @default(now())updatedAt DateTime @updatedAt++ @@unique([domainSlug, slug])+}++model Domain {+ id String @id @default(cuid())+ slug String @unique+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)+ userId String+ verified Boolean @default(false) // Whether the domain has been verified+ lastChecked DateTime @default(now())+ createdAt DateTime @default(now())+ updatedAt DateTime @updatedAt+ links Link[] // links associated with this domain}+model View {id String @id @default(cuid())link Link @relation(fields: [linkId], references: [id])