From 347ced2c655a0a8ef7eecc8b060c0fcbff0e398d Mon Sep 17 00:00:00 2001 From: Hexagonn <128217934+hexaaagon@users.noreply.github.com> Date: Sun, 3 Nov 2024 02:30:12 +0000 Subject: [PATCH] fix(front): fix `window is not defined` --- src/app/page.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 02dd6a1..cd9b7b4 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -43,7 +43,6 @@ export default function Home() { const [userId, setUserId] = useState(null); const [userError, setUserError] = useState(); const [userData, setUserData] = useState<{ userId: string } | null>(null); - const originUrl = useMemo(() => window.location?.origin, []); const [copyState, setCopyState] = useState("Copy"); const [outputType, setOutputType] = useState<"markdown" | "html" | "url">( "markdown", @@ -64,7 +63,7 @@ export default function Home() { curve: [0, 1, 0, 1], }); - const url = `${originUrl || "https://lanyard.cnrad.dev"}/api/${userData?.userId}${option.length > 0 ? `?${option.map((o) => `${o.name}=${o.value}`).join("&")}` : ""}`; + const url = `${typeof window !== "undefined" ? window.location?.origin : "https://lanyard.cnrad.dev"}/api/${userData?.userId}${option.length > 0 ? `?${option.map((o) => `${o.name}=${o.value}`).join("&")}` : ""}`; function outputText() { if (outputType === "html") {