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.

revert middleware changes for now

Steven Tey9e8ef38fcbff
diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.ts
index fe16d4d635..a102091ba5 100644
--- a/apps/web/lib/middleware/link.ts
+++ b/apps/web/lib/middleware/link.ts
@@ -26,7 +26,6 @@ import {
import { linkCache } from "../api/links/cache";
import { getLinkViaEdge } from "../planetscale";
import { getDomainViaEdge } from "../planetscale/get-domain-via-edge";
-import { importBitlyLink } from "./bitly";
import { hasEmptySearchParams } from "./utils/has-empty-search-params";
export default async function LinkMiddleware(
@@ -69,38 +68,25 @@ export default async function LinkMiddleware(
let link = await linkCache.get({ domain, key });
if (!link) {
- let linkData = await getLinkViaEdge(domain, key);
+ const linkData = await getLinkViaEdge(domain, key);
if (!linkData) {
- if (domain === "buff.ly") {
- const newLink = await importBitlyLink(`buff.ly/${key}`);
-
- if (newLink) {
- linkData = newLink;
- }
- }
-
- 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,
- },
- );
- }
+ // 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,
+ });
}
}