use universal cookies

This commit is contained in:
Khaleel Al-Adhami 2025-01-30 13:31:33 -08:00
parent ce3dd5c3c6
commit 40f7b865d8
2 changed files with 6 additions and 6 deletions

View File

@ -112,12 +112,9 @@ export const getBackendURL = (url_str) => {
* @returns True if the backend is disabled, false otherwise. * @returns True if the backend is disabled, false otherwise.
*/ */
export const isBackendDisabled = () => { export const isBackendDisabled = () => {
const cookie = document.cookie const backendEnabled = cookies.get("backend-enabled");
.split("; ") return backendEnabled === "false";
.find((row) => row.startsWith("backend-enabled="));
return cookie !== undefined && cookie.split("=")[1] == "false";
}; };
/** /**
* Determine if any event in the event queue is stateful. * Determine if any event in the event queue is stateful.
* *

View File

@ -4,6 +4,7 @@ from __future__ import annotations
from typing import Optional from typing import Optional
from reflex import constants
from reflex.components.component import Component from reflex.components.component import Component
from reflex.components.core.cond import cond from reflex.components.core.cond import cond
from reflex.components.datadisplay.logo import svg_logo from reflex.components.datadisplay.logo import svg_logo
@ -318,7 +319,9 @@ class BackendDisabled(Div):
"useEffect(() => { setBackendDisabled(isBackendDisabled()); }, []);": None, "useEffect(() => { setBackendDisabled(isBackendDisabled()); }, []);": None,
}, },
imports={ imports={
f"$/{constants.Dirs.STATE_PATH}": [ImportVar(tag="isBackendDisabled")], f"$/{constants.Dirs.STATE_PATH}": [
ImportVar(tag="isBackendDisabled")
],
}, },
), ),
) )