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.

Small changes, added logs to debug middleware

Steven Teya2aaba04faa2
diff --git a/app/protected/[domain]/[key]/form.tsx b/app/protected/[domain]/[key]/form.tsx
index 7d331f2568..21903222a4 100644
--- a/app/protected/[domain]/[key]/form.tsx
+++ b/app/protected/[domain]/[key]/form.tsx
@@ -8,8 +8,6 @@ import { AlertCircleFill } from "@/components/shared/icons";
import Button from "#/ui/button";
import { toast } from "sonner";
-export const runtime = "edge";
-
export default function PasswordForm() {
const { domain, key } = useParams() as {
domain: string;
diff --git a/app/protected/[domain]/[key]/page.tsx b/app/protected/[domain]/[key]/page.tsx
index 1adf01f605..304c801ec1 100644
--- a/app/protected/[domain]/[key]/page.tsx
+++ b/app/protected/[domain]/[key]/page.tsx
@@ -2,6 +2,8 @@ import { constructMetadata } from "#/lib/utils";
import BlurImage from "#/ui/blur-image";
import PasswordForm from "./form";
+export const runtime = "edge";
+
const title = "Password Required";
const description =
"This link is password protected. Please enter the password to view it.";
diff --git a/app/ui/home/hero.tsx b/app/ui/home/hero.tsx
index 7840088584..ade67cabad 100644
--- a/app/ui/home/hero.tsx
+++ b/app/ui/home/hero.tsx
@@ -6,11 +6,11 @@ const Hero = () => {
return (
<div className="mx-auto mb-10 mt-12 max-w-md px-2.5 text-center sm:max-w-lg sm:px-0">
<Link
- href="/changelog/team-invites"
+ href="/changelog/new-tag-creation-flow"
className="group mx-auto flex max-w-fit items-center justify-center space-x-2 overflow-hidden rounded-full border border-gray-200 bg-white px-7 py-2 shadow-[inset_10px_-50px_94px_0_rgb(199,199,199,0.1)] backdrop-blur transition-all hover:border-gray-300 hover:bg-white/50"
>
<p className="text-sm font-semibold text-gray-700">
- Introducing Team Invites
+ New Tag Creation Flow
</p>
<ExpandingArrow className="-ml-1 h-3.5 w-3.5" />
</Link>
diff --git a/lib/middleware/root.ts b/lib/middleware/root.ts
index 9dc73a5363..144d121667 100644
--- a/lib/middleware/root.ts
+++ b/lib/middleware/root.ts
@@ -12,6 +12,8 @@ export default async function RootMiddleware(
) {
const { domain } = parse(req);
+ console.log("domain", domain, "isHomeHostname", isHomeHostname(domain));
+
if (!domain) {
return NextResponse.next();
}
diff --git a/lib/middleware/utils.ts b/lib/middleware/utils.ts
index 436d9f4180..a5c8e56935 100644
--- a/lib/middleware/utils.ts
+++ b/lib/middleware/utils.ts
@@ -13,6 +13,7 @@ export const parse = (req: NextRequest) => {
const key = decodeURIComponent(path.split("/")[1]); // key is the first part of the path (e.g. dub.sh/stats/github -> stats)
const fullKey = decodeURIComponent(path.slice(1)); // fullKey is the full path without the first slash (to account for multi-level subpaths, e.g. dub.sh/github/repo -> github/repo)
+ console.log({ domain, path, key, fullKey });
return { domain, path, key, fullKey };
};
@@ -21,7 +22,7 @@ export const getFinalUrl = (target: string, { req }: { req: NextRequest }) => {
const searchParams = req.nextUrl.searchParams;
// get the query params of the target url
- const targetUrl = new URL(target);
+ const targetUrl = new URL(decodeURIComponent(target));
// if searchParams (type: `URLSearchParams`) has the same key as target url, then overwrite it
for (const [key, value] of searchParams) {