The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add DUB_API_URL
Tim Wilson930e3c2cf503
diff --git a/apps/web/.env.example b/apps/web/.env.exampleindex 526548585c..8a16df31b2 100644--- a/apps/web/.env.example+++ b/apps/web/.env.example@@ -119,4 +119,7 @@ PANGEA_API_KEY=SLACK_APP_INSTALL_URL=SLACK_CLIENT_ID=SLACK_CLIENT_SECRET=-SLACK_SIGNING_SECRET=\ No newline at end of file+SLACK_SIGNING_SECRET=++# Dub API base URL override (e.g. https://api.dub.co or http://localhost:8888/api)+DUB_API_URL=\ No newline at end of filediff --git a/apps/web/lib/actions/get-total-events.ts b/apps/web/lib/actions/get-total-events.tsindex 90bad021a3..41b1941cff 100644--- a/apps/web/lib/actions/get-total-events.ts+++ b/apps/web/lib/actions/get-total-events.ts@@ -1,3 +1,4 @@+import { DUB_API_URL } from "@dub/utils";import { unstable_cache } from "next/cache";export const getTotalEvents = unstable_cache(async (linkId: string) => {@@ -8,7 +9,7 @@ export const getTotalEvents = unstable_cache(async (linkId: string) => {// })return await fetch(- `https://api.dub.co/analytics?event=composite&groupBy=count&interval=all_unfiltered&linkId=${linkId}`,+ `${DUB_API_URL}/analytics?event=composite&groupBy=count&interval=all_unfiltered&linkId=${linkId}`,{headers: {Authorization: `Bearer ${process.env.DUB_API_KEY}`,diff --git a/packages/utils/src/constants/main.ts b/packages/utils/src/constants/main.tsindex a598c86dbf..20f046aa9e 100644--- a/packages/utils/src/constants/main.ts+++ b/packages/utils/src/constants/main.ts@@ -45,6 +45,8 @@ export const ADMIN_HOSTNAMES = new Set(["admin.localhost:8888",]);+export const DUB_API_URL = process.env.DUB_API_URL || "https://api.dub.co";+export const DUB_LOGO = "https://assets.dub.co/logo.png";export const DUB_WORDMARK = "https://assets.dub.co/wordmark.png";export const DUB_THUMBNAIL = "https://assets.dub.co/thumbnail.jpg";