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.

Tweak the condition

Kiran K368a9d2132e6
diff --git a/apps/web/lib/auth/index.ts b/apps/web/lib/auth/index.ts
index 1adb3ded19..0c71686f63 100644
--- a/apps/web/lib/auth/index.ts
+++ b/apps/web/lib/auth/index.ts
@@ -123,7 +123,7 @@ export const withAuth = (
try {
// if there's no projectSlug defined
- if (!slug) {
+ if (!slug && !workspaceId) {
// for /api/links (POST /api/links) – allow no session (but warn if user provides apiKey)
if (allowAnonymous && !apiKey) {
// @ts-expect-error
@@ -133,17 +133,15 @@ export const withAuth = (
searchParams,
headers,
});
+ } else {
+ throw new DubApiError({
+ code: "not_found",
+ message:
+ "Workspace id not found. Did you forget to include a `workspaceId` 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,