The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
On-demand link import
Steven Tey673b30de8583
diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.tsindex a102091ba5..fd39c114b1 100644--- a/apps/web/lib/middleware/link.ts+++ b/apps/web/lib/middleware/link.ts@@ -68,25 +68,30 @@ export default async function LinkMiddleware(let link = await linkCache.get({ domain, key });if (!link) {- const linkData = await getLinkViaEdge(domain, key);+ let linkData = await getLinkViaEdge(domain, key);if (!linkData) {- // check if domain has notFoundUrl configured- const domainData = await getDomainViaEdge(domain);- if (domainData?.notFoundUrl) {- return NextResponse.redirect(domainData.notFoundUrl, {- headers: {- ...DUB_HEADERS,- "X-Robots-Tag": "googlebot: noindex",- // pass the Referer value to the not found URL- Referer: req.url,- },- status: 302,- });- } else {- return NextResponse.rewrite(new URL(`/${domain}/not-found`, req.url), {- headers: DUB_HEADERS,- });+ if (!linkData) {+ // check if domain has notFoundUrl configured+ const domainData = await getDomainViaEdge(domain);+ if (domainData?.notFoundUrl) {+ return NextResponse.redirect(domainData.notFoundUrl, {+ headers: {+ ...DUB_HEADERS,+ "X-Robots-Tag": "googlebot: noindex",+ // pass the Referer value to the not found URL+ Referer: req.url,+ },+ status: 302,+ });+ } else {+ return NextResponse.rewrite(+ new URL(`/${domain}/not-found`, req.url),+ {+ headers: DUB_HEADERS,+ },+ );+ }}}