fix: use BASE_URL config for redirect_url if available (#6995)

Co-authored-by: Michael Genson <genson.michael@gmail.com>
This commit is contained in:
whattheschnell
2026-02-03 16:31:20 -06:00
committed by GitHub
parent d31c07a6c5
commit f82f387146
3 changed files with 12 additions and 1 deletions

View File

@@ -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`)"""

View File

@@ -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

View File

@@ -27,6 +27,7 @@ services:
network_mode: host
environment:
ALLOW_SIGNUP: True
BASE_URL: http://localhost:9000
DB_ENGINE: sqlite
OIDC_AUTH_ENABLED: True