Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🐛 Route every participant link through the short base URL (#3248)
Luke Vella097238288426
diff --git a/apps/landing/next.config.ts b/apps/landing/next.config.tsindex 63c9517fd..731684203 100644--- a/apps/landing/next.config.ts+++ b/apps/landing/next.config.ts@@ -83,6 +83,11 @@ const nextConfig: NextConfig = {destination: createAppUrl("/invite/:path*"),permanent: true,},+ {+ source: "/e/:path*",+ destination: createAppUrl("/e/:path*"),+ permanent: true,+ },{source: "/admin/:path*",destination: createAppUrl("/admin/:path*"),diff --git a/apps/web/.env.sample b/apps/web/.env.sampleindex 0008d63c3..480902c0a 100644--- a/apps/web/.env.sample+++ b/apps/web/.env.sample@@ -6,6 +6,11 @@ SECRET_PASSWORD=# Example: https://example.comNEXT_PUBLIC_BASE_URL=https://web.rallly.test+# Optional. Base url for links handed to participants (poll invites, event+# pages) when they should live on another domain that redirects here.+# Defaults to NEXT_PUBLIC_BASE_URL.+# NEXT_PUBLIC_SHORT_BASE_URL=https://example.com+# A connection string to your Postgres databaseDATABASE_URL=postgres://postgres:postgres@localhost:5450/ralllydiff --git a/apps/web/src/env.ts b/apps/web/src/env.tsindex 7e1149b0d..ed671ff9e 100644--- a/apps/web/src/env.ts+++ b/apps/web/src/env.ts@@ -203,6 +203,12 @@ export const env = createEnv({* If not set, assets are proxied through Next.js (current behaviour).*/NEXT_PUBLIC_CDN_BASE_URL: z.url().optional(),+ /**+ * Base URL for links handed to participants (poll invites, event pages).+ * Lets those links live on a marketing domain that redirects to this+ * instance. Defaults to `NEXT_PUBLIC_BASE_URL`.+ */+ NEXT_PUBLIC_SHORT_BASE_URL: z.url().optional(),/*** Domain to attach to server-set cookies (auth session, locale).* Set to a parent domain prefixed with a leading dot (e.g. `.rallly.co`)@@ -287,6 +293,7 @@ export const env = createEnv({API_BASE_URL: process.env.API_BASE_URL,NEXT_PUBLIC_TURNSTILE_SITE_KEY: process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY,NEXT_PUBLIC_CDN_BASE_URL: process.env.NEXT_PUBLIC_CDN_BASE_URL,+ NEXT_PUBLIC_SHORT_BASE_URL: process.env.NEXT_PUBLIC_SHORT_BASE_URL,// Empty string means unset: the process env can override an .env file// value but never remove it, so this is the only way a dev server on// plain localhost can neutralize a configured cookie domain.diff --git a/apps/web/src/features/poll/invite/mutations.ts b/apps/web/src/features/poll/invite/mutations.tsindex c2cb271e0..ff868c0ab 100644--- a/apps/web/src/features/poll/invite/mutations.ts+++ b/apps/web/src/features/poll/invite/mutations.ts@@ -3,7 +3,7 @@ import "server-only";import { Prisma, prisma } from "@rallly/database";import { sendPollInviteEmail } from "@rallly/emails/templates/poll-invite";import { createLogger } from "@rallly/logger";-import { absoluteUrl } from "@rallly/utils/absolute-url";+import { shortUrl } from "@rallly/utils/absolute-url";import { getInstanceBranding, getSpaceBranding } from "@/emails/branding";import { resolveSpaceTier } from "@/features/billing/utils";import { recordPollActivities } from "@/features/poll/activity/mutations";@@ -182,7 +182,7 @@ export async function sendPollInvite({props: {hostName: sender.name,pollTitle: poll.title,- inviteUrl: absoluteUrl(getPollInvitePath({ pollId, token })),+ inviteUrl: shortUrl(getPollInvitePath({ pollId, token })),},});} catch (error) {diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.tsindex 99f77a44a..2f09dc508 100644--- a/apps/web/src/trpc/routers/polls.ts+++ b/apps/web/src/trpc/routers/polls.ts@@ -1180,7 +1180,7 @@ export const polls = router({content: event.value,},props: {- pollUrl: absoluteUrl(`/invite/${poll.id}`),+ pollUrl: shortUrl(`/invite/${poll.id}`),title: poll.title,hostName: poll.user?.name ?? "",date,diff --git a/apps/web/src/trpc/routers/polls/invites.ts b/apps/web/src/trpc/routers/polls/invites.tsindex d49a75dd8..c2147a492 100644--- a/apps/web/src/trpc/routers/polls/invites.ts+++ b/apps/web/src/trpc/routers/polls/invites.ts@@ -1,4 +1,4 @@-import { absoluteUrl } from "@rallly/utils/absolute-url";+import { shortUrl } from "@rallly/utils/absolute-url";import { TRPCError } from "@trpc/server";import * as z from "zod";import { hasPollAdminAccess } from "@/features/poll/data";@@ -24,7 +24,7 @@ export const invites = router({id: invite.id,email: invite.email,status: derivePollInviteStatus(invite),- inviteUrl: absoluteUrl(+ inviteUrl: shortUrl(getPollInvitePath({ pollId: input.pollId, token: invite.token }),),}));diff --git a/apps/web/src/trpc/routers/polls/participants.ts b/apps/web/src/trpc/routers/polls/participants.tsindex 484e2f331..f11a18e07 100644--- a/apps/web/src/trpc/routers/polls/participants.ts+++ b/apps/web/src/trpc/routers/polls/participants.ts@@ -3,7 +3,7 @@ import { prisma } from "@rallly/database";import { sendNewParticipantEmail } from "@rallly/emails/templates/new-participant";import { sendNewParticipantConfirmationEmail } from "@rallly/emails/templates/new-participant-confirmation";import { createLogger } from "@rallly/logger";-import { absoluteUrl } from "@rallly/utils/absolute-url";+import { absoluteUrl, shortUrl } from "@rallly/utils/absolute-url";import { TRPCError } from "@trpc/server";import { after } from "next/server";import * as z from "zod";@@ -180,7 +180,7 @@ export const participants = router({const participants = rawParticipants.map((participant) => {const dto = createParticipantFullDTO(participant);const editUrl = isAdmin- ? absoluteUrl(getPollInvitePath({ pollId, token: participant.token }))+ ? shortUrl(getPollInvitePath({ pollId, token: participant.token })): null;if (isAdmin || isOwn(participant)) {return { ...dto, editUrl };@@ -459,7 +459,7 @@ export const participants = router({: await getInstanceBranding(),props: {title: participant.poll.title,- editSubmissionUrl: absoluteUrl(+ editSubmissionUrl: shortUrl(`/invite/${participant.poll.id}?token=${editToken}`,),},