From 7386bb35e537058ef928cf8fa28ab6b8f6a795e5 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 28 Sep 2025 00:16:51 +0300 Subject: [PATCH] fix(website): yet another case of server-side rendering failing --- apps/website/src/download-helper.ts | 6 ++++-- apps/website/src/pages/GetStarted/get-started.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/website/src/download-helper.ts b/apps/website/src/download-helper.ts index 2e153f04c..4d427ae8b 100644 --- a/apps/website/src/download-helper.ts +++ b/apps/website/src/download-helper.ts @@ -181,7 +181,9 @@ export function buildDownloadUrl(app: App, platform: Platform, format: string, a } } -export function getArchitecture(): Architecture { +export function getArchitecture(): Architecture | null { + if (typeof window === "undefined") return null; + const userAgent = navigator.userAgent.toLowerCase(); if (userAgent.includes('arm64') || userAgent.includes('aarch64')) { return 'arm64'; @@ -208,7 +210,7 @@ export function getRecommendedDownload() { const architecture = getArchitecture(); const platform = getPlatform(); - if (!platform) return null; + if (!platform || !architecture) return null; const downloadInfo = downloadMatrix.desktop[platform]?.downloads; const recommendedDownload = Object.entries(downloadInfo || {}).find(d => d[1].recommended); diff --git a/apps/website/src/pages/GetStarted/get-started.tsx b/apps/website/src/pages/GetStarted/get-started.tsx index bce0ac373..b22546f27 100644 --- a/apps/website/src/pages/GetStarted/get-started.tsx +++ b/apps/website/src/pages/GetStarted/get-started.tsx @@ -10,7 +10,7 @@ import "./get-started.css"; import packageJson from "../../../../../package.json" with { type: "json" }; export default function DownloadPage() { - const [ currentArch, setCurrentArch ] = useState(getArchitecture()); + const [ currentArch, setCurrentArch ] = useState(getArchitecture() ?? "x64"); usePageTitle("Download"); return (