From f2918849215ed3f8e56ca5875835385ac083c3eb Mon Sep 17 00:00:00 2001 From: sabaimran Date: Tue, 17 Dec 2024 15:44:18 -0800 Subject: [PATCH] If not in debug mode, force google auth to use the https protocol --- src/khoj/processor/conversation/google/utils.py | 1 - src/khoj/processor/conversation/offline/chat_model.py | 1 - src/khoj/routers/auth.py | 5 +++++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/khoj/processor/conversation/google/utils.py b/src/khoj/processor/conversation/google/utils.py index 5f24362b..8060ea5e 100644 --- a/src/khoj/processor/conversation/google/utils.py +++ b/src/khoj/processor/conversation/google/utils.py @@ -27,7 +27,6 @@ from khoj.processor.conversation.utils import ( from khoj.utils import state from khoj.utils.helpers import ( get_chat_usage_metrics, - in_debug_mode, is_none_or_empty, is_promptrace_enabled, ) diff --git a/src/khoj/processor/conversation/offline/chat_model.py b/src/khoj/processor/conversation/offline/chat_model.py index 5ce45bac..f727fd1d 100644 --- a/src/khoj/processor/conversation/offline/chat_model.py +++ b/src/khoj/processor/conversation/offline/chat_model.py @@ -23,7 +23,6 @@ from khoj.utils import state from khoj.utils.constants import empty_escape_sequences from khoj.utils.helpers import ( ConversationCommand, - in_debug_mode, is_none_or_empty, is_promptrace_enabled, truncate_code_context, diff --git a/src/khoj/routers/auth.py b/src/khoj/routers/auth.py index 022d4c92..03cb174e 100644 --- a/src/khoj/routers/auth.py +++ b/src/khoj/routers/auth.py @@ -28,6 +28,7 @@ from khoj.routers.helpers import ( update_telemetry_state, ) from khoj.utils import state +from khoj.utils.helpers import in_debug_mode logger = logging.getLogger(__name__) @@ -214,6 +215,10 @@ async def auth(request: Request): # 1. Construct the full redirect URI including domain base_url = str(request.base_url).rstrip("/") + + if not in_debug_mode(): + base_url = base_url.replace("http://", "https://") + redirect_uri = f"{base_url}{request.app.url_path_for('auth')}" payload = {