From f82f387146287bf6aeca832834688464ba44c0e2 Mon Sep 17 00:00:00 2001 From: whattheschnell Date: Tue, 3 Feb 2026 16:31:20 -0600 Subject: [PATCH] fix: use BASE_URL config for redirect_url if available (#6995) Co-authored-by: Michael Genson --- mealie/core/settings/settings.py | 5 +++++ mealie/routes/auth/auth.py | 7 ++++++- tests/e2e/docker/docker-compose.yml | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mealie/core/settings/settings.py b/mealie/core/settings/settings.py index 655f3c4d5..e2bcfa6f9 100644 --- a/mealie/core/settings/settings.py +++ b/mealie/core/settings/settings.py @@ -110,6 +110,11 @@ class AppSettings(AppLoggingSettings): BASE_URL: str = "http://localhost:8080" """trailing slashes are trimmed (ex. `http://localhost:8080/` becomes ``http://localhost:8080`)""" + @property + def is_default_base_url(self) -> bool: + """Returns True if BASE_URL has not been changed from the default.""" + return self.BASE_URL == "http://localhost:8080" + STATIC_FILES: str = str(PACKAGE_DIR / "frontend") """path to static files directory (ex. `mealie/dist`)""" diff --git a/mealie/routes/auth/auth.py b/mealie/routes/auth/auth.py index 56b94ade7..91ab58976 100644 --- a/mealie/routes/auth/auth.py +++ b/mealie/routes/auth/auth.py @@ -99,7 +99,12 @@ async def oauth_login(request: Request): # in development, we want to redirect to the frontend redirect_url = "http://localhost:3000/login" else: - redirect_url = URLPath("/login").make_absolute_url(request.base_url) + # Prioritize User Configuration over Request Headers. + if not settings.is_default_base_url: + base = settings.BASE_URL or request.base_url + else: + base = request.base_url + redirect_url = URLPath("/login").make_absolute_url(base) response: RedirectResponse = await client.authorize_redirect(request, redirect_url) return response diff --git a/tests/e2e/docker/docker-compose.yml b/tests/e2e/docker/docker-compose.yml index 44cfdb12e..eacc1e40b 100644 --- a/tests/e2e/docker/docker-compose.yml +++ b/tests/e2e/docker/docker-compose.yml @@ -27,6 +27,7 @@ services: network_mode: host environment: ALLOW_SIGNUP: True + BASE_URL: http://localhost:9000 DB_ENGINE: sqlite OIDC_AUTH_ENABLED: True