diff --git a/.env.example b/.env.example index c9bcc4ba9..da1ef7e6c 100644 --- a/.env.example +++ b/.env.example @@ -12,6 +12,7 @@ GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= NEXT_PUBLIC_BASE_URL=http://localhost:3000 +NEXT_PUBLIC_MARKETING_URL=http://localhost:3000 # This variable is from Resend to send emails RESEND_API_KEY= diff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsx index ce4bab051..79332feb0 100644 --- a/components/documents/add-document-modal.tsx +++ b/components/documents/add-document-modal.tsx @@ -138,7 +138,7 @@ export function AddDocumentModal({ if (!newVersion) { // copy the link to the clipboard copyToClipboard( - `${process.env.NEXT_PUBLIC_BASE_URL}/view/${document.links[0].id}`, + `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${document.links[0].id}`, "Document uploaded and link copied to clipboard. Redirecting to document page...", ); @@ -309,7 +309,7 @@ export function AddDocumentModal({ if (!newVersion) { // copy the link to the clipboard copyToClipboard( - `${process.env.NEXT_PUBLIC_BASE_URL}/view/${document.links[0].id}`, + `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${document.links[0].id}`, "Notion Page processed and link copied to clipboard. Redirecting to document page...", ); diff --git a/components/documents/document-card.tsx b/components/documents/document-card.tsx index 25125a5d8..515681c21 100644 --- a/components/documents/document-card.tsx +++ b/components/documents/document-card.tsx @@ -63,7 +63,7 @@ export default function DocumentsCard({ function handleCopyToClipboard(id: string) { copyToClipboard( - `${process.env.NEXT_PUBLIC_BASE_URL}/view/${id}`, + `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${id}`, "Link copied to clipboard.", ); } diff --git a/components/emails/deleted-domain.tsx b/components/emails/deleted-domain.tsx index 2ce496848..1a376d90b 100644 --- a/components/emails/deleted-domain.tsx +++ b/components/emails/deleted-domain.tsx @@ -43,7 +43,7 @@ export default function DomainDeleted({
diff --git a/components/web/footer.tsx b/components/web/footer.tsx index 159d7b826..8dbd0cdf8 100644 --- a/components/web/footer.tsx +++ b/components/web/footer.tsx @@ -120,7 +120,7 @@ const navigation = { // }, { name: "Virtual sales data room", - href: "https://www.papermark.io/solutions/virtual-sales-room", + href: "/solutions/virtual-sales-room", }, ], support: [ diff --git a/components/welcome/notion-form.tsx b/components/welcome/notion-form.tsx index 25eb652f5..76378ba3a 100644 --- a/components/welcome/notion-form.tsx +++ b/components/welcome/notion-form.tsx @@ -178,7 +178,7 @@ export default function NotionForm() { } copyToClipboard( - `${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`, + `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`, "Link copied to clipboard. Redirecting to document page...", ); @@ -313,7 +313,7 @@ export default function NotionForm() {

- {`${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`} + {`${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`}

diff --git a/components/welcome/special-upload.tsx b/components/welcome/special-upload.tsx index 24fc2d895..990df02c5 100644 --- a/components/welcome/special-upload.tsx +++ b/components/welcome/special-upload.tsx @@ -182,7 +182,7 @@ export default function DeckGeneratorUpload() { } copyToClipboard( - `${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`, + `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`, "Link copied to clipboard. Redirecting to document page...", ); @@ -322,7 +322,7 @@ export default function DeckGeneratorUpload() {

- {`${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`} + {`${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`}

diff --git a/components/welcome/upload.tsx b/components/welcome/upload.tsx index 93981ce60..2396b9a5e 100644 --- a/components/welcome/upload.tsx +++ b/components/welcome/upload.tsx @@ -162,7 +162,7 @@ export default function Upload() { } copyToClipboard( - `${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`, + `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`, "Link copied to clipboard. Redirecting to document page...", ); @@ -302,7 +302,7 @@ export default function Upload() {

- {`${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`} + {`${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`}

diff --git a/lib/middleware/domain.ts b/lib/middleware/domain.ts index 8b740a423..a1c872571 100644 --- a/lib/middleware/domain.ts +++ b/lib/middleware/domain.ts @@ -21,6 +21,8 @@ export default async function DomainMiddleware(req: NextRequest) { return NextResponse.rewrite(url, PAPERMARK_HEADERS); } else { // redirect plain custom domain to papermark.io, eventually to it's own landing page - return NextResponse.redirect(new URL("https://www.papermark.io", req.url)); + return NextResponse.redirect( + new URL("https://www.papermark.io/home", req.url), + ); } } diff --git a/next.config.mjs b/next.config.mjs index 54b1372e4..bac26af57 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,3 +1,13 @@ +const REDIRECT_SEGMENTS = [ + "documents", + "datarooms", + "settings", + "api", + "_static", + "_icons", + "_example", +]; + /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, @@ -20,11 +30,34 @@ const nextConfig = { }, async redirects() { return [ - { - source: "/view/d/:path*", - destination: "/view/:path*", - permanent: true, - }, + ...REDIRECT_SEGMENTS.map( + (segment) => ( + { + source: `/${segment}`, + has: [ + { + type: "host", + value: "www.papermark.io", + }, + ], + destination: `https://app.papermark.io/${segment}`, + permanent: true, + statusCode: 301, + }, + { + source: `/${segment}/:path*`, + has: [ + { + type: "host", + value: "www.papermark.io", + }, + ], + destination: `https://app.papermark.io/${segment}/:path*`, + permanent: true, + statusCode: 301, + } + ), + ), ]; }, async rewrites() { @@ -49,6 +82,7 @@ function prepareRemotePatterns() { { protocol: "https", hostname: "lh3.googleusercontent.com" }, // papermark img { protocol: "https", hostname: "www.papermark.io" }, + { protocol: "https", hostname: "app.papermark.io" }, // useragent img { protocol: "https", hostname: "faisalman.github.io" }, // special document pages diff --git a/pages/api/jobs/send-dataroom-new-document-notification.ts b/pages/api/jobs/send-dataroom-new-document-notification.ts index e598e036c..d7c5eeaae 100644 --- a/pages/api/jobs/send-dataroom-new-document-notification.ts +++ b/pages/api/jobs/send-dataroom-new-document-notification.ts @@ -102,7 +102,7 @@ export default async function handle( senderEmail: user.email!, documentName: document?.document.name, to: viewer.email, - url: `${process.env.NEXTAUTH_URL}/view/${linkId}?email=${encodeURIComponent(viewer.email)}`, + url: `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${linkId}?email=${encodeURIComponent(viewer.email)}`, }); res diff --git a/pages/api/jobs/send-dataroom-view-invitation.ts b/pages/api/jobs/send-dataroom-view-invitation.ts index 9109d7306..98080ce23 100644 --- a/pages/api/jobs/send-dataroom-view-invitation.ts +++ b/pages/api/jobs/send-dataroom-view-invitation.ts @@ -85,7 +85,7 @@ export default async function handle( dataroomName: viewer.dataroom.name, senderEmail: user.email!, to: viewer.email, - url: `${process.env.NEXTAUTH_URL}/view/${linkId}?email=${encodeURIComponent(viewer.email)}`, + url: `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${linkId}?email=${encodeURIComponent(viewer.email)}`, }); res diff --git a/pages/api/views-dataroom.ts b/pages/api/views-dataroom.ts index 74124dd83..015e8e1c7 100644 --- a/pages/api/views-dataroom.ts +++ b/pages/api/views-dataroom.ts @@ -202,7 +202,7 @@ export default async function handle( }); // set the default verification url - let verificationUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/view/${linkId}/?token=${token}&email=${encodeURIComponent(email)}`; + let verificationUrl: string = `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${linkId}/?token=${token}&email=${encodeURIComponent(email)}`; if (link.domainSlug && link.slug) { // if custom domain is enabled, use the custom domain diff --git a/pages/api/views.ts b/pages/api/views.ts index 1ad99044c..43a90a07e 100644 --- a/pages/api/views.ts +++ b/pages/api/views.ts @@ -190,7 +190,7 @@ export default async function handle( // set the default verification url let verificationUrl: string = - `${process.env.NEXT_PUBLIC_BASE_URL}/view/${linkId}/?token=${token}&email=${encodeURIComponent(email)}` + + `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${linkId}/?token=${token}&email=${encodeURIComponent(email)}` + (previewToken ? `&previewToken=${previewToken}` : ""); if (link.domainSlug && link.slug && !previewToken) {