diff --git a/src/utils/colorPreference.ts b/src/utils/colorPreference.ts index 3d971ad4..4103f456 100644 --- a/src/utils/colorPreference.ts +++ b/src/utils/colorPreference.ts @@ -4,7 +4,7 @@ export const prefersDarkMode = (cookieString: string): boolean => { const regex = /(?<=\bcolor_mode=)[^;]+/g; const match = regex.exec(cookieString); const cookie = match && JSON.parse(decodeURIComponent(match[0])); - const colorScheme: ColorScheme = cookie.color_mode ?? "auto"; + const colorScheme: ColorScheme = cookie?.color_mode ?? "auto"; if (colorScheme === "auto") { return window.matchMedia("(prefers-color-scheme: dark)").matches;