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.

fixes

Kiran K736e76e442db
diff --git a/apps/web/app/[domain]/page.tsx b/apps/web/app/[domain]/page.tsx
index b55001c74d..3883687323 100644
--- a/apps/web/app/[domain]/page.tsx
+++ b/apps/web/app/[domain]/page.tsx
@@ -22,21 +22,27 @@ export async function generateMetadata({
}
export async function generateStaticParams() {
- const domains =
- process.env.VERCEL_ENV === "production"
- ? await prisma.domain.findMany({
- where: {
- verified: true,
- target: null,
- NOT: {
- slug: "dub.sh",
- },
- },
- select: {
- slug: true,
- },
- })
- : [];
+ if (process.env.VERCEL_ENV != "production") {
+ return [];
+ }
+
+ const domains = await prisma.domain.findMany({
+ where: {
+ verified: true,
+ NOT: {
+ slug: "dub.sh",
+ },
+ links: {
+ some: {
+ url: "",
+ },
+ },
+ },
+ select: {
+ slug: true,
+ },
+ });
+
return domains.map(({ slug: domain }) => ({
domain,
}));
diff --git a/apps/web/lib/api/domains/delete-domain-links.ts b/apps/web/lib/api/domains/delete-domain-links.ts
index d6f1943384..b3ed4cef42 100644
--- a/apps/web/lib/api/domains/delete-domain-links.ts
+++ b/apps/web/lib/api/domains/delete-domain-links.ts
@@ -47,7 +47,7 @@ export async function deleteDomainAndLinks(domain: string) {
waitUntil(
(async () => {
- const res = await Promise.allSettled([
+ await Promise.allSettled([
// delete all links from redis
redis.del(domain.toLowerCase()),
// record deletes in tinybird for domain & links
diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.ts
index a8f1e4c577..a390259c4c 100644
--- a/apps/web/lib/auth/workspace.ts
+++ b/apps/web/lib/auth/workspace.ts
@@ -14,6 +14,7 @@ import {
} from "@dub/utils";
import { Link as LinkProps } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
+import { getDomain } from "../api/domains/get-domain";
import { hashToken } from "./hash-token";
import { Session, getSession } from "./utils";
@@ -239,22 +240,16 @@ export const withWorkspace = (
: { id: linkId }),
},
})
- : domain &&
- key &&
- (key === "_root"
- ? prisma.domain.findUnique({
- where: {
- slug: domain,
+ : domain && key
+ ? prisma.link.findUnique({
+ where: {
+ domain_key: {
+ domain,
+ key,
},
- })
- : prisma.link.findUnique({
- where: {
- domain_key: {
- domain,
- key,
- },
- },
- })),
+ },
+ })
+ : undefined,
])) as [WorkspaceProps, LinkProps | undefined];
if (!workspace || !workspace.users) {
@@ -393,11 +388,7 @@ export const withWorkspace = (
// special case for getting domain by ID
// TODO: refactor domains to use the same logic as links
if (!link && searchParams.checkDomain === "true") {
- const domain = await prisma.domain.findUnique({
- where: {
- id: linkId,
- },
- });
+ const domain = await getDomain({ id: linkId! });
if (domain) {
link = {
...domain,