Skip to content

Commit

Permalink
feat: migrate from www to app
Browse files Browse the repository at this point in the history
  • Loading branch information
mfts committed Aug 2, 2024
1 parent 565c84f commit 310c813
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 41 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions components/documents/add-document-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
);

Expand Down Expand Up @@ -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...",
);

Expand Down
2 changes: 1 addition & 1 deletion components/documents/document-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
);
}
Expand Down
2 changes: 1 addition & 1 deletion components/emails/deleted-domain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function DomainDeleted({
<Section className="my-8 text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/settings/domains`}
href={`https://app.papermark.io/settings/domains`}
style={{ padding: "12px 20px" }}
>
Set up your custom domain
Expand Down
4 changes: 2 additions & 2 deletions components/emails/invalid-domain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function InvalidDomain({
<Section className="my-8 text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/settings/domains`}
href={`https://app.papermark.io/settings/domains`}
style={{ padding: "12px 20px" }}
>
Configure domain
Expand All @@ -60,7 +60,7 @@ export default function InvalidDomain({
<Text className="text-sm leading-6 text-black">
If you do not want to keep this domain on Papermark, you can{" "}
<Link
href={`https://www.papermark.io/settings/domains`}
href={`https://app.papermark.io/settings/domains`}
className="font-medium text-blue-600 no-underline"
>
delete it
Expand Down
2 changes: 1 addition & 1 deletion components/emails/onboarding-1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Onboarding1Email = () => {
<Section className="mb-[32px] mt-[32px] text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
href={`https://app.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
style={{ padding: "12px 20px" }}
>
Upload my documents
Expand Down
2 changes: 1 addition & 1 deletion components/emails/onboarding-2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Onboarding2Email = () => {
<Section className="mb-[32px] mt-[32px] text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
href={`https://app.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
style={{ padding: "12px 20px" }}
>
To my link settings
Expand Down
2 changes: 1 addition & 1 deletion components/emails/onboarding-3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Onboarding3Email = () => {
<Section className="mb-[32px] mt-[32px] text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
href={`https://app.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
style={{ padding: "12px 20px" }}
>
View your document activity
Expand Down
2 changes: 1 addition & 1 deletion components/emails/onboarding-4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Onboarding4Email = () => {
<Section className="mb-[32px] mt-[32px] text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
href={`https://app.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
style={{ padding: "12px 20px" }}
>
Add your domain and branding
Expand Down
2 changes: 1 addition & 1 deletion components/emails/onboarding-5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const Onboarding3Email = () => {
<Section className="mb-[32px] mt-[32px] text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
href={`https://app.papermark.io/documents?utm_source=onboarding&utm_medium=email&utm_campaign=20240723&utm_content=upload_documents`}
style={{ padding: "12px 20px" }}
>
Create new data room
Expand Down
4 changes: 2 additions & 2 deletions components/emails/trial-end-final-reminder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const TrialEndFinalReminderEmail = ({ name }: TrialEndFinalReminderEmail) => {
</Text>
<Text className="text-sm leading-6 text-black">
Your Papermark Pro trial expires in 24 hours.{" "}
<Link href={`https://www.papermark.io/settings/billing`}>
<Link href={`https://app.papermark.io/settings/billing`}>
Upgrade now
</Link>{" "}
to:
Expand All @@ -60,7 +60,7 @@ const TrialEndFinalReminderEmail = ({ name }: TrialEndFinalReminderEmail) => {
<Section className="mb-[32px] mt-[32px] text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/settings/billing`}
href={`https://app.papermark.io/settings/billing`}
style={{ padding: "12px 20px" }}
>
Upgrade now
Expand Down
2 changes: 1 addition & 1 deletion components/emails/trial-end-reminder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const TrialEndReminderEmail = ({ name }: TrialEndReminderEmail) => {
<Section className="mb-[32px] mt-[32px] text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/settings/billing`}
href={`https://app.papermark.io/settings/billing`}
style={{ padding: "12px 20px" }}
>
Upgrade your plan
Expand Down
2 changes: 1 addition & 1 deletion components/emails/viewed-dataroom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function ViewedDataroom({
<Section className="my-8 text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/datarooms/${dataroomId}`}
href={`https://app.papermark.io/datarooms/${dataroomId}`}
style={{ padding: "12px 20px" }}
>
See my dataroom insights
Expand Down
2 changes: 1 addition & 1 deletion components/emails/viewed-document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function ViewedDocument({
<Section className="my-8 text-center">
<Button
className="rounded bg-black text-center text-xs font-semibold text-white no-underline"
href={`https://www.papermark.io/documents/${documentId}`}
href={`https://app.papermark.io/documents/${documentId}`}
style={{ padding: "12px 20px" }}
>
See my document insights
Expand Down
8 changes: 4 additions & 4 deletions components/links/links-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function LinksTable({
}

const { previewToken } = await response.json();
const previewLink = `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}?previewToken=${previewToken}`;
const previewLink = `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}?previewToken=${previewToken}`;

window.open(previewLink, "_blank");
};
Expand Down Expand Up @@ -270,7 +270,7 @@ export default function LinksTable({
<div className="flex w-full whitespace-nowrap text-xs group-hover/cell:opacity-0 md:text-sm">
{link.domainId
? `https://${link.domainSlug}/${link.slug}`
: `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}`}
: `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}`}
</div>

{link.domainId && hasFreePlan ? (
Expand All @@ -290,7 +290,7 @@ export default function LinksTable({
handleCopyToClipboard(
link.domainId
? `https://${link.domainSlug}/${link.slug}`
: `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}`,
: `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}`,
)
}
title="Copy to clipboard"
Expand Down Expand Up @@ -479,7 +479,7 @@ export default function LinksTable({
<div className="flex items-center gap-x-4 whitespace-nowrap rounded-sm bg-secondary px-3 py-1.5 text-xs text-secondary-foreground sm:py-1 sm:text-sm">
{link.domainId
? `https://${link.domainSlug}/${link.slug}`
: `https://${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/view/${link.id}`}
: `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${link.id}`}
</div>
</TableCell>
<TableCell>
Expand Down
8 changes: 4 additions & 4 deletions components/web/alternatives/docsendtext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ const DocSendAlternatives = () => {
</>

<Link
href="https://papermark.io/login"
href="https://www.papermark.io/login"
target="_blank"
rel="noopener noreferrer"
>
Expand Down Expand Up @@ -1388,7 +1388,7 @@ const DocSendAlternatives = () => {
</ul>

<Link
href="https://papermark.io/login"
href="https://www.papermark.io/login"
target="_blank"
rel="noopener noreferrer"
>
Expand Down Expand Up @@ -1629,7 +1629,7 @@ const DocSendAlternatives = () => {
</div>
</Link>
<Link
href="https://papermark.io/login"
href="https://www.papermark.io/login"
target="_blank"
rel="noopener noreferrer"
>
Expand All @@ -1641,7 +1641,7 @@ const DocSendAlternatives = () => {
</Button>
</Link>
<Link
href="https://papermark.io/pricing"
href="https://www.papermark.io/pricing"
target="_blank"
rel="noopener noreferrer"
>
Expand Down
2 changes: 1 addition & 1 deletion components/web/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
4 changes: 2 additions & 2 deletions components/welcome/notion-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
);

Expand Down Expand Up @@ -313,7 +313,7 @@ export default function NotionForm() {
<div className="flex py-8">
<div className="flex w-full max-w-xs focus-within:z-10 sm:max-w-lg">
<p className="block w-full overflow-y-scroll rounded-md border-0 bg-secondary px-4 py-1.5 text-left leading-6 text-secondary-foreground md:min-w-[500px]">
{`${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`}
{`${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`}
</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/welcome/special-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
);

Expand Down Expand Up @@ -322,7 +322,7 @@ export default function DeckGeneratorUpload() {
<div className="flex py-8">
<div className="flex w-full max-w-xs focus-within:z-10 sm:max-w-lg">
<p className="block w-full overflow-y-scroll rounded-md border-0 bg-secondary px-4 py-1.5 text-left leading-6 text-secondary-foreground md:min-w-[500px]">
{`${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`}
{`${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`}
</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/welcome/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
);

Expand Down Expand Up @@ -302,7 +302,7 @@ export default function Upload() {
<div className="flex py-8">
<div className="flex w-full max-w-xs focus-within:z-10 sm:max-w-lg">
<p className="block w-full overflow-y-scroll rounded-md border-0 bg-secondary px-4 py-1.5 text-left leading-6 text-secondary-foreground md:min-w-[500px]">
{`${process.env.NEXT_PUBLIC_BASE_URL}/view/${currentLinkId}`}
{`${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${currentLinkId}`}
</p>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion lib/middleware/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
}
44 changes: 39 additions & 5 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const REDIRECT_SEGMENTS = [
"documents",
"datarooms",
"settings",
"api",
"_static",
"_icons",
"_example",
];

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
Expand All @@ -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() {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/api/jobs/send-dataroom-new-document-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/api/jobs/send-dataroom-view-invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/api/views-dataroom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/api/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 310c813

Please sign in to comment.