The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Restrict usage of free .link domains to pro+ users
Tim Wilsoncb6c229959de
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.tsindex fe5a8e38a2..faf38653a7 100644--- a/apps/web/lib/api/links/process-link.ts+++ b/apps/web/lib/api/links/process-link.ts@@ -142,6 +142,9 @@ export async function processLink<T extends Record<string, any>>({const domains = workspace? await prisma.domain.findMany({where: { projectId: workspace.id },+ include: {+ registeredDomain: true,+ },}): [];@@ -215,6 +218,19 @@ export async function processLink<T extends Record<string, any>>({error: "Domain does not belong to workspace.",code: "forbidden",};++ // else, check if the domain is a free .link and whether the workspace is pro++ } else if (+ domain.endsWith(".link") &&+ workspace?.plan === "free" &&+ domains?.find((d) => d.slug === domain)?.registeredDomain+ ) {+ return {+ link: payload,+ error:+ "You can only use your free .link domain on a Pro plan and above. Upgrade to Pro to use this domain.",+ code: "forbidden",+ };}if (!key) {