diff --git a/reflex/components/core/banner.py b/reflex/components/core/banner.py index 8160faf38c5..5846309473f 100644 --- a/reflex/components/core/banner.py +++ b/reflex/components/core/banner.py @@ -16,6 +16,7 @@ from reflex.components.radix.themes.layout.flex import Flex from reflex.components.radix.themes.typography.text import Text from reflex.components.sonner.toast import ToastProps, toast_ref +from reflex.config import get_config from reflex.constants import Dirs, Hooks, Imports from reflex.constants.compiler import CompileVars from reflex.environment import environment @@ -100,9 +101,13 @@ def add_hooks(self) -> list[str | Var]: """ toast_id = "websocket-error" target_url = WebsocketTargetURL.create() + config = get_config() + is_dev_mode = environment.REFLEX_ENV_MODE.get().value == constants.Env.DEV props = ToastProps( description=LiteralVar.create( - f"Check if server is reachable at {target_url}", + f"Check if server is reachable at {target_url}" + if is_dev_mode or not config.connection_error_message + else config.connection_error_message ), close_button=True, duration=120000, @@ -135,6 +140,8 @@ def add_hooks(self) -> list[str | Var]: else: loading_message = Var.create( f"Cannot connect to server: {connection_error}." + if is_dev_mode or not config.connection_error_message + else "" ) toast_var = Var( f"toast?.error({loading_message!s}, {{...toast_props, onDismiss: () => setUserDismissed(true)}},)" diff --git a/reflex/config.py b/reflex/config.py index 81441ff4c5a..d666a8541b8 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -262,6 +262,8 @@ class BaseConfig: _prefixes: ClassVar[list[str]] = ["REFLEX_"] + connection_error_message: str | None = None + _PLUGINS_ENABLED_BY_DEFAULT = [ SitemapPlugin,