Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
added a comment in domain
jeet1desaicde3587f66c7
diff --git a/lib/middleware/domain.ts b/lib/middleware/domain.tsindex 6d04e22a..4f77db57 100644--- a/lib/middleware/domain.ts+++ b/lib/middleware/domain.ts@@ -1,8 +1,10 @@import { NextRequest, NextResponse } from "next/server";+import { getToken } from "next-auth/jwt";import { PAPERMARK_HEADERS } from "../constants";export default async function DomainMiddleware(req: NextRequest) {const path = req.nextUrl.pathname;+ const host = req.headers.get("host");// clone the URL so we can modify itconst url = req.nextUrl.clone();@@ -10,7 +12,8 @@ export default async function DomainMiddleware(req: NextRequest) {// if there's a path and it's not "/" then we need to check if it's a custom domainif (path !== "/") {// Subdomain available, rewriting- url.pathname = `${path}`;+ // >>> Rewriting: ${path} to /view/domains/${host}${path}`+ url.pathname = `/view/domains/${host}${path}`;return NextResponse.rewrite(url, PAPERMARK_HEADERS);} else {// redirect plain custom domain to papermark.io, eventually to it's own landing page