Skip to content

Open-source status page, incident response and uptime monitoring

fix: custom domain prefix (#1538)

Maximilian Kaske929612018be2
diff --git a/apps/status-page/src/hooks/use-pathname-prefix.ts b/apps/status-page/src/hooks/use-pathname-prefix.ts
index 4bb79a526..4a52b7a59 100644
--- a/apps/status-page/src/hooks/use-pathname-prefix.ts
+++ b/apps/status-page/src/hooks/use-pathname-prefix.ts
@@ -1,25 +1,36 @@
"use client";
+import { useTRPC } from "@/lib/trpc/client";
+import { useQuery } from "@tanstack/react-query";
+import { useParams } from "next/navigation";
import { useEffect, useState } from "react";
export function usePathnamePrefix() {
+ const trpc = useTRPC();
+ const { domain } = useParams<{ domain: string }>();
+ const { data: page } = useQuery(
+ trpc.statusPage.get.queryOptions({ slug: domain }),
+ );
const [prefix, setPrefix] = useState("");
useEffect(() => {
if (typeof window !== "undefined") {
const hostnames = window.location.hostname.split(".");
const pathnames = window.location.pathname.split("/");
+ const isCustomDomain = window.location.hostname === page?.customDomain;
+
if (
- hostnames.length > 2 &&
- hostnames[0] !== "www" &&
- !window.location.hostname.endsWith(".vercel.app")
+ isCustomDomain ||
+ (hostnames.length > 2 &&
+ hostnames[0] !== "www" &&
+ !window.location.hostname.endsWith(".vercel.app"))
) {
setPrefix("");
} else {
setPrefix(pathnames[1]);
}
}
- }, []);
+ }, [page?.customDomain]);
return prefix;
}