Skip to content

Commit 44c8f94

Browse files
committed
Try to figure out why cookie aren't working on versel
1 parent f9feb7d commit 44c8f94

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/lib/darkMode.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,23 @@ export function startObservingColorSchemeHtmlAttribute() {
7272

7373
{
7474
const setColorSchemeCookie = (colorScheme: ColorScheme) => {
75+
console.log("DEBUG: setColorSchemeCookie");
76+
7577
let newCookie = `${data_fr_theme}=${colorScheme};path=/;max-age=31536000`;
7678

7779
//We do not set the domain if we are on localhost or an ip
7880
if (window.location.hostname.match(/\.[a-zA-Z]{2,}$/)) {
81+
console.log("DEBUG: Append to newCookie");
82+
7983
newCookie += `;domain=${
8084
window.location.hostname.split(".").length >= 3
8185
? window.location.hostname.replace(/^[^.]+\./, "")
8286
: window.location.hostname
8387
}`;
8488
}
8589

90+
console.log(`DEBUG: set newCookie: ${newCookie}`);
91+
8692
document.cookie = newCookie;
8793
};
8894

src/lib/start.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export async function startDsfrReact(params: Params) {
6767
);
6868
}
6969

70+
console.log("DEBUG: startObservingColorSchemeHtmlAttribute");
71+
7072
startObservingColorSchemeHtmlAttribute();
7173

7274
(window as any).dsfr = { verbose, "mode": "manual" };

0 commit comments

Comments
 (0)