From d4fb2a1af055aab3b10f862894707de12158b05f Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Sat, 24 Jun 2023 12:28:10 +0200 Subject: [PATCH] fix(enterprise): respect root for login url when not mounted under / See https://github.com/widgetti/solara/issues/157#issuecomment-1605208315 --- packages/solara-enterprise/solara_enterprise/auth/utils.py | 3 ++- solara/server/settings.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/solara-enterprise/solara_enterprise/auth/utils.py b/packages/solara-enterprise/solara_enterprise/auth/utils.py index 0e51d9bb0..3f3b6d37f 100644 --- a/packages/solara-enterprise/solara_enterprise/auth/utils.py +++ b/packages/solara-enterprise/solara_enterprise/auth/utils.py @@ -32,4 +32,5 @@ def get_login_url(return_to_path: Optional[str] = None): return_to_path = return_to_path[1:] assert settings.main.base_url is not None redirect_uri = urllib.parse.quote(settings.main.base_url + return_to_path) - return f"/_solara/auth/login?redirect_uri={redirect_uri}" + root = settings.main.root_path or "" + return f"{root}/_solara/auth/login?redirect_uri={redirect_uri}" diff --git a/solara/server/settings.py b/solara/server/settings.py index 51adaa834..7a970df0d 100644 --- a/solara/server/settings.py +++ b/solara/server/settings.py @@ -123,7 +123,7 @@ class MainSettings(pydantic.BaseSettings): mode: str = "production" tracer: bool = False timing: bool = False - root_path: Optional[str] = None # e.g. /myapp/ + root_path: Optional[str] = None # e.g. /myapp (without trailing slash) base_url: str = "" # e.g. https://myapp.solara.run/myapp/ platform: str = sys.platform