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.

fix geo-targeting

Steven Tey9b492aed707c
diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.ts
index 4cb52b6c2c..b996b90c9a 100644
--- a/apps/web/lib/middleware/link.ts
+++ b/apps/web/lib/middleware/link.ts
@@ -143,6 +143,7 @@ export default async function LinkMiddleware(
id: linkId,
password,
trackConversion,
+ geo: geoTargeting,
proxy,
rewrite,
expiresAt,
@@ -156,8 +157,6 @@ export default async function LinkMiddleware(
projectId: workspaceId,
} = cachedLink;
- const geo = geolocation(req);
-
const testUrl = await resolveABTestURL({
testVariants,
testCompletedAt,
@@ -501,8 +500,8 @@ export default async function LinkMiddleware(
cookieData,
);
- // redirect to geo-specific link if it is specified and the user is in the specified country
- } else if (geo && country && country in geo) {
+ // redirect to geo-targeting link if it is specified and the user is in the specified country
+ } else if (geoTargeting && country && country in geoTargeting) {
ev.waitUntil(
recordClick({
req,
@@ -510,7 +509,7 @@ export default async function LinkMiddleware(
linkId,
domain,
key,
- url: geo[country],
+ url: geoTargeting[country],
webhookIds,
workspaceId,
shouldCacheClickId,
@@ -519,7 +518,7 @@ export default async function LinkMiddleware(
return createResponseWithCookies(
NextResponse.redirect(
- getFinalUrl(geo[country], {
+ getFinalUrl(geoTargeting[country], {
req,
...(shouldCacheClickId && { clickId }),
...(isPartnerLink && { via: key }),