From 40f7b865d8a4fb857065e50b3f4596789de226d0 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Thu, 30 Jan 2025 13:31:33 -0800 Subject: [PATCH] use universal cookies --- reflex/.templates/web/utils/state.js | 7 ++----- reflex/components/core/banner.py | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reflex/.templates/web/utils/state.js b/reflex/.templates/web/utils/state.js index 009910a32..a431ca4f1 100644 --- a/reflex/.templates/web/utils/state.js +++ b/reflex/.templates/web/utils/state.js @@ -112,12 +112,9 @@ export const getBackendURL = (url_str) => { * @returns True if the backend is disabled, false otherwise. */ export const isBackendDisabled = () => { - const cookie = document.cookie - .split("; ") - .find((row) => row.startsWith("backend-enabled=")); - return cookie !== undefined && cookie.split("=")[1] == "false"; + const backendEnabled = cookies.get("backend-enabled"); + return backendEnabled === "false"; }; - /** * Determine if any event in the event queue is stateful. * diff --git a/reflex/components/core/banner.py b/reflex/components/core/banner.py index 92d3a8424..882975f2f 100644 --- a/reflex/components/core/banner.py +++ b/reflex/components/core/banner.py @@ -4,6 +4,7 @@ from __future__ import annotations from typing import Optional +from reflex import constants from reflex.components.component import Component from reflex.components.core.cond import cond from reflex.components.datadisplay.logo import svg_logo @@ -318,7 +319,9 @@ class BackendDisabled(Div): "useEffect(() => { setBackendDisabled(isBackendDisabled()); }, []);": None, }, imports={ - f"$/{constants.Dirs.STATE_PATH}": [ImportVar(tag="isBackendDisabled")], + f"$/{constants.Dirs.STATE_PATH}": [ + ImportVar(tag="isBackendDisabled") + ], }, ), )