From ab703b6dedc562f01db27a4cb79ef57bd29535f7 Mon Sep 17 00:00:00 2001 From: Wang Qi Date: Mon, 3 Aug 2026 13:48:35 +0800 Subject: [PATCH] Fix: Cache the SECRET_KEY, if it is not set, RAGFlow will auto gen one, but if Redis evict keys due to lack of memory, it will cause re-generate secret key, that cause all requests 401 (#17707) --- common/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/settings.py b/common/settings.py index a28d09a0eb..bf540dbc91 100644 --- a/common/settings.py +++ b/common/settings.py @@ -175,7 +175,8 @@ def init_secret_key(): def get_secret_key(): global SECRET_KEY if SECRET_KEY is None: - return _get_or_create_secret_key() + # Why need cache it, if REDIS evict keys due to lack of memory, new secret key will be generated, cause all requests 401 + SECRET_KEY = _get_or_create_secret_key() return SECRET_KEY