Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

633 B
Raw Blame
import { prisma } from "@/lib/prisma";
import { APP_DOMAIN } from "@dub/utils";
import { redirect } from "next/navigation";

export default async function OldStatsPage(props: {
  params: Promise<{ domain: string; key: string }>;
}) {
  const params = await props.params;
  const domain = params.domain;
  const key = decodeURIComponent(params.key);

  const link = await prisma.link.findUnique({
    where: {
      domain_key: {
        domain,
        key,
      },
    },
    select: {
      dashboard: true,
    },
  });

  if (!link?.dashboard) {
    redirect("/");
  }

  redirect(`${APP_DOMAIN}/share/${link.dashboard.id}`);
}