The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix rewrite sequence
Steven Teyd6532b160040
diff --git a/lib/middleware/link.ts b/lib/middleware/link.tsindex 54e84b4f3f..8a690e3acd 100644--- a/lib/middleware/link.ts+++ b/lib/middleware/link.ts@@ -91,8 +91,14 @@ export default async function LinkMiddleware(const { country } =process.env.VERCEL === "1" && req.geo ? req.geo : LOCALHOST_GEO_DATA;- // rewrite to target URL if link cloaking is enabled- if (rewrite) {+ // rewrite to proxy page (/_proxy/[domain]/[key]) if it's a bot and proxy is enabled+ if (isBot && proxy) {+ return NextResponse.rewrite(+ new URL(`/proxy/${domain}/${encodeURIComponent(key)}`, req.url),+ );++ // rewrite to target URL if link cloaking is enabled+ } else if (rewrite) {if (iframeable) {return NextResponse.rewrite(new URL(`/rewrite/${target}`, req.url),@@ -103,12 +109,6 @@ export default async function LinkMiddleware(return NextResponse.rewrite(decodeURIComponent(target), DUB_HEADERS);}- // rewrite to proxy page (/_proxy/[domain]/[key]) if it's a bot and proxy is enabled- } else if (isBot && proxy) {- return NextResponse.rewrite(- new URL(`/proxy/${domain}/${encodeURIComponent(key)}`, req.url),- );-// redirect to iOS link if it is specified and the user is on an iOS device} else if (ios && userAgent(req).os?.name === "iOS") {return NextResponse.redirect(getFinalUrl(ios, { req }), DUB_HEADERS);