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.

Remove patch-redirect workaround

Steven Tey362b67db3a70
diff --git a/apps/web/app/api/patch-redirect/route.ts b/apps/web/app/api/patch-redirect/route.ts
deleted file mode 100644
index 273234cdcf..0000000000
--- a/apps/web/app/api/patch-redirect/route.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { DUB_HEADERS } from "@dub/utils";
-import { NextRequest, NextResponse } from "next/server";
-
-export function GET(req: NextRequest) {
- const redirectDestination = req.headers.get("destination");
-
- if (!redirectDestination) {
- console.error("missing redirect destination");
- return NextResponse.json({ invalid: true });
- }
-
- return NextResponse.redirect(redirectDestination, {
- headers: DUB_HEADERS,
- status: 302,
- });
-}
diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.ts
index d31b999e75..b926b4e9d5 100644
--- a/apps/web/lib/middleware/link.ts
+++ b/apps/web/lib/middleware/link.ts
@@ -31,7 +31,6 @@ import { clickCache } from "../api/links/click-cache";
import { getLinkViaEdge } from "../planetscale";
import { getDomainViaEdge } from "../planetscale/get-domain-via-edge";
import { getPartnerAndDiscount } from "../planetscale/get-partner-discount";
-import { hasEmptySearchParams } from "./utils/has-empty-search-params";
import { resolveABTestURL } from "./utils/resolve-ab-test-url";
export default async function LinkMiddleware(
@@ -513,22 +512,6 @@ export default async function LinkMiddleware(
}),
);
- if (hasEmptySearchParams(url)) {
- return createResponseWithCookies(
- NextResponse.rewrite(new URL("/api/patch-redirect", req.url), {
- request: {
- headers: new Headers({
- destination: getFinalUrl(url, {
- req,
- clickId: shouldPassClickId ? clickId : undefined,
- }),
- }),
- },
- }),
- cookieData,
- );
- }
-
return createResponseWithCookies(
NextResponse.redirect(
getFinalUrl(url, {