The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed a few more ts errors
Steven Teyd990eb683a57
diff --git a/apps/web/lib/middleware/root.ts b/apps/web/lib/middleware/root.tsindex fbd1888f01..a90df84187 100644--- a/apps/web/lib/middleware/root.ts+++ b/apps/web/lib/middleware/root.ts@@ -22,8 +22,8 @@ export default async function RootMiddleware(const linkData = await getDomainViaEdge(domain);if (!linkData) {- // short link not found, redirect to root- return NextResponse.redirect(new URL("/", req.url), DUB_HEADERS);+ // rewrite to placeholder page if domain doesn't exist+ return NextResponse.rewrite(new URL(`/${domain}`, req.url));}// format link to fit the RedisLinkProps interface@@ -41,22 +41,22 @@ export default async function RootMiddleware(// record clicks on root pageev.waitUntil(recordClick({ req, id, domain, projectId }));- if (url) {- if (rewrite) {- if (iframeable) {- return NextResponse.rewrite(- new URL(`/rewrite/${url}`, req.url),- DUB_HEADERS,- );- } else {- // if link is not iframeable, use Next.js rewrite instead- return NextResponse.rewrite(url, DUB_HEADERS);- }+ if (!url) {+ // rewrite to placeholder page unless the user defines a site to redirect to+ return NextResponse.rewrite(new URL(`/${domain}`, req.url));+ }++ if (rewrite) {+ if (iframeable) {+ return NextResponse.rewrite(+ new URL(`/rewrite/${url}`, req.url),+ DUB_HEADERS,+ );} else {- return NextResponse.redirect(url, DUB_HEADERS);+ // if link is not iframeable, use Next.js rewrite instead+ return NextResponse.rewrite(url, DUB_HEADERS);}} else {- // rewrite to root page unless the user defines a site to redirect to- return NextResponse.rewrite(new URL(`/${domain}`, req.url));+ return NextResponse.redirect(url, DUB_HEADERS);}}diff --git a/packages/utils/src/constants/index.ts b/packages/utils/src/constants/index.tsindex 00389f9b75..36b810c8a9 100644--- a/packages/utils/src/constants/index.ts+++ b/packages/utils/src/constants/index.ts@@ -109,6 +109,10 @@ export const DUB_LOGO = "https://d2vwwcvoksz7ty.cloudfront.net/logo.png";export const DUB_THUMBNAIL ="https://d2vwwcvoksz7ty.cloudfront.net/thumbnail.png";+export const DUB_PROJECT_ID = "cl7pj5kq4006835rbjlt2ofka";+export const LEGAL_PROJECT_ID = "clrflia0j0000vs7sqfhz9c7q";+export const LEGAL_USER_ID = "clqei1lgc0000vsnzi01pbf47";+export const HIDE_BACKGROUND_SEGMENTS = ["stats","changelog",@@ -119,6 +123,7 @@ export const HIDE_BACKGROUND_SEGMENTS = [export const DUB_DOMAINS = [{+ id: "clce1z7ch00j0rbstbjufva4j",slug: SHORT_DOMAIN,verified: true,primary: true,@@ -128,10 +133,12 @@ export const DUB_DOMAINS = [placeholder: "https://dub.co/help/article/what-is-dub",clicks: 0,allowedHostnames: [],+ projectId: DUB_PROJECT_ID,},...(process.env.NEXT_PUBLIC_IS_DUB? [{+ id: "clce1z7cs00y8rbstk4xtnj0k",slug: "chatg.pt",verified: true,primary: false,@@ -141,8 +148,10 @@ export const DUB_DOMAINS = [placeholder: "https://chat.openai.com/g/g-UGjKKONEe-domainsgpt",clicks: 0,allowedHostnames: ["chat.openai.com"],+ projectId: DUB_PROJECT_ID,},{+ id: "cloxw8qtk000bjt08n9b812vs",slug: "amzn.id",verified: true,primary: false,@@ -152,8 +161,10 @@ export const DUB_DOMAINS = [placeholder: "https://www.amazon.com/dp/B0BW4SWNC8",clicks: 0,allowedHostnames: ["amazon.com", "amazon.co.uk", "amazon.ca"],+ projectId: DUB_PROJECT_ID,},{+ id: "cloxw8y2u0003js08a7mqg1j8",slug: "spti.fi",verified: true,primary: false,@@ -163,6 +174,7 @@ export const DUB_DOMAINS = [placeholder: "https://open.spotify.com/album/1SCyi9a5pOasikidToUY5y",clicks: 0,allowedHostnames: ["open.spotify.com"],+ projectId: DUB_PROJECT_ID,},]: []),@@ -220,10 +232,6 @@ export const DEFAULT_LINK_PROPS = {proxy: false,};-export const DUB_PROJECT_ID = "cl7pj5kq4006835rbjlt2ofka";-export const LEGAL_PROJECT_ID = "clrflia0j0000vs7sqfhz9c7q";-export const LEGAL_USER_ID = "clqei1lgc0000vsnzi01pbf47";-export const SAML_PROVIDERS = [{name: "Okta",