The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed home hostname
Steven Teyc11f5c750519
diff --git a/lib/middleware/utils.ts b/lib/middleware/utils.tsindex 905ca0e1b0..49915fa13b 100644--- a/lib/middleware/utils.ts+++ b/lib/middleware/utils.ts@@ -1,10 +1,11 @@import { NextRequest } from "next/server";import { HOME_HOSTNAMES } from "@/lib/constants";+import { isHomeHostname } from "../utils";export const parse = (req: NextRequest) => {let domain = req.headers.get("host") as string;domain = domain.replace("www.", ""); // remove www. from domain- if (HOME_HOSTNAMES.has(domain)) domain = "dub.sh";+ if (isHomeHostname(domain)) domain = "dub.sh"; // if domain is a home hostname, set it to dub.shconst path = req.nextUrl.pathname;const key = decodeURIComponent(path.split("/")[1]); // decodeURIComponentto handle foreign languages like Hebrewconst fullKey = decodeURIComponent(path).slice(1);diff --git a/middleware.ts b/middleware.tsindex 586bfe87b8..abda9c4545 100644--- a/middleware.ts+++ b/middleware.ts@@ -26,7 +26,6 @@ export const config = {export default async function middleware(req: NextRequest, ev: NextFetchEvent) {const { domain, path, key } = parse(req);- const home = isHomeHostname(domain);// for App (e.g. app.dub.sh)if (APP_HOSTNAMES.has(domain)) {@@ -48,7 +47,7 @@ export default async function middleware(req: NextRequest, ev: NextFetchEvent) {return RootMiddleware(req, ev);}- if (home) {+ if (domain === "dub.sh") {if (DEFAULT_REDIRECTS[key]) {return NextResponse.redirect(DEFAULT_REDIRECTS[key]);}