From d4c3cfbabaa74ff535a6bbb047fbafd6cf3db53f Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 23 May 2025 01:03:28 +0400 Subject: [PATCH] refac: oauth redirect url to use WEBUI_URL --- backend/open_webui/utils/oauth.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index f6004515f..de3355859 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -536,5 +536,10 @@ class OAuthManager: secure=WEBUI_AUTH_COOKIE_SECURE, ) # Redirect back to the frontend with the JWT token - redirect_url = f"{request.base_url}auth#token={jwt_token}" + + redirect_base_url = request.app.state.config.WEBUI_URL or request.base_url + if redirect_base_url.endswith("/"): + redirect_base_url = redirect_base_url[:-1] + redirect_url = f"{redirect_base_url}/auth#token={jwt_token}" + return RedirectResponse(url=redirect_url, headers=response.headers)