From 67a354f49f93ba6257d825d730c4c679b3d7cf99 Mon Sep 17 00:00:00 2001 From: Mavis Bot Date: Wed, 5 Aug 2026 21:38:16 +0000 Subject: [PATCH] fix : handled undefined window in getOrigin to prevent SSR errors --- utils/urls.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/urls.ts b/utils/urls.ts index 319179156..4a6b6c3f9 100644 --- a/utils/urls.ts +++ b/utils/urls.ts @@ -12,9 +12,8 @@ const FALLBACK_ORIGIN = 'https://commitpulse.vercel.app'; */ export function getOrigin(): string { const envOrigin = process.env.NEXT_PUBLIC_SITE_URL?.trim() || null; - return ( - (typeof window !== 'undefined' ? window.location.origin : null) ?? envOrigin ?? FALLBACK_ORIGIN - ); + const browserOrigin = (typeof window !== 'undefined' && window != null) ? window.location.origin : null; + return browserOrigin ?? envOrigin ?? FALLBACK_ORIGIN; } /**