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.

support workspaceId query param

Kiran K23af8fa38963
diff --git a/apps/web/lib/auth/index.ts b/apps/web/lib/auth/index.ts
index 7f17ee38c4..832c57403f 100644
--- a/apps/web/lib/auth/index.ts
+++ b/apps/web/lib/auth/index.ts
@@ -115,6 +115,7 @@ export const withAuth = (
let headers = {};
const slug = params?.slug || searchParams.projectSlug;
+ const workspaceId = searchParams?.workspaceId;
try {
// if there's no projectSlug defined
@@ -128,15 +129,17 @@ export const withAuth = (
searchParams,
headers,
});
- } else {
- throw new DubApiError({
- code: "not_found",
- message:
- "Project slug not found. Did you forget to include a `projectSlug` query parameter?",
- });
}
}
+ if (!slug && !workspaceId) {
+ throw new DubApiError({
+ code: "not_found",
+ message:
+ "Workspace id not found. Did you forget to include a `workspaceId` query parameter?",
+ });
+ }
+
if (apiKey) {
const hashedKey = hashToken(apiKey, {
noSecret: true,
@@ -209,7 +212,8 @@ export const withAuth = (
let [project, link] = (await Promise.all([
prisma.project.findUnique({
where: {
- slug,
+ slug: slug || undefined,
+ id: workspaceId || undefined,
},
select: {
id: true,