Skip to content

Open-source personal finance manager. Self-hosted, privacy-first.

fix(compose): stop podman-compose appending "}" to FRONTEND_URL (#1193)

Shayn Hornik6d2034744e2f
diff --git a/backend/app/core/config.py b/backend/app/core/config.py
index 11b3b367..1c7e5c39 100644
--- a/backend/app/core/config.py
+++ b/backend/app/core/config.py
@@ -52,6 +52,9 @@ class Settings(BaseSettings):
# Frontend
frontend_url: str = "http://localhost:5173"
+ # Docker Compose passes FRONTEND_URL empty when it is not set, plus the
+ # published port; an empty FRONTEND_URL becomes http://localhost:<port>.
+ frontend_port: int = 3000
# WebAuthn / passkeys
webauthn_rp_name: str = "Securo"
@@ -142,6 +145,12 @@ class Settings(BaseSettings):
def oidc_login_available(self) -> bool:
return bool(self.oidc_enabled and self.oidc_client_id and self.oidc_discovery_url)
+ @model_validator(mode="after")
+ def default_frontend_url(self) -> "Settings":
+ if not self.frontend_url:
+ self.frontend_url = f"http://localhost:{self.frontend_port}"
+ return self
+
@model_validator(mode="after")
def validate_auth_settings(self) -> "Settings":
if not self.local_auth_enabled and not self.oidc_login_available:
diff --git a/backend/tests/test_config.py b/backend/tests/test_config.py
index 2dc8fa79..cf309f4e 100644
--- a/backend/tests/test_config.py
+++ b/backend/tests/test_config.py
@@ -161,3 +161,19 @@ def test_local_auth_disabled_requires_complete_oidc_configuration(
local_auth_enabled=False,
_secrets_dir=str(secrets),
)
+
+
+def test_empty_frontend_url_uses_frontend_port(monkeypatch):
+ """docker-compose.yml passes FRONTEND_URL empty when unset (no nested
+ default, which podman-compose < 1.6.0 mangles: #1162) plus FRONTEND_PORT."""
+ monkeypatch.setenv("FRONTEND_URL", "")
+ monkeypatch.setenv("FRONTEND_PORT", "3132")
+
+ assert Settings(_env_file=None).frontend_url == "http://localhost:3132"
+
+
+def test_set_frontend_url_is_used_as_is(monkeypatch):
+ monkeypatch.setenv("FRONTEND_URL", "https://securo.example.com")
+ monkeypatch.setenv("FRONTEND_PORT", "3132")
+
+ assert Settings(_env_file=None).frontend_url == "https://securo.example.com"
diff --git a/docker-compose.yml b/docker-compose.yml
index 91e37417..d0388f67 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -11,7 +11,11 @@ x-backend-env: &backend-env
DATABASE_URL: postgresql+asyncpg://postgres:postgres@db:5432/securo
SECRET_KEY: ${SECRET_KEY:-dev-secret-change-in-production}
DEBUG: ${DEBUG:-true}
- FRONTEND_URL: ${FRONTEND_URL:-http://localhost:${FRONTEND_PORT:-3000}}
+ # Not nested (${FRONTEND_URL:-http://localhost:${FRONTEND_PORT:-3000}}):
+ # podman-compose before 1.6.0 leaves a stray "}" on such values (#1162).
+ # Empty FRONTEND_URL makes the backend use http://localhost:$FRONTEND_PORT.
+ FRONTEND_URL: ${FRONTEND_URL:-}
+ FRONTEND_PORT: ${FRONTEND_PORT:-3000}
WEBAUTHN_RP_NAME: ${WEBAUTHN_RP_NAME:-Securo}
WEBAUTHN_RP_ID: ${WEBAUTHN_RP_ID:-}
WEBAUTHN_ORIGIN: ${WEBAUTHN_ORIGIN:-}
@@ -136,7 +140,7 @@ services:
environment:
BACKEND_URL: http://backend:8000
# Also drives Vite's allowedHosts, so a proxied domain is not blocked.
- FRONTEND_URL: ${FRONTEND_URL:-http://localhost:${FRONTEND_PORT:-3000}}
+ FRONTEND_URL: ${FRONTEND_URL:-}
APP_VERSION_ROOT: /workspace
depends_on:
- backend
diff --git a/install.sh b/install.sh
index e42ddd9c..4fe781c6 100755
--- a/install.sh
+++ b/install.sh
@@ -104,37 +104,6 @@ is_docker_compose_v2() {
command -v docker-compose > /dev/null 2>&1 && docker-compose version 2>/dev/null | grep -Eq 'Docker Compose version v?2|v2'
}
-version_at_least() {
- local version="${1%%[-+]*}"
- local minimum="${2%%[-+]*}"
- local IFS=.
- local -a version_parts minimum_parts
- local version_part minimum_part i
-
- [ -n "$version" ] || return 1
-
- read -r -a version_parts <<< "$version"
- read -r -a minimum_parts <<< "$minimum"
-
- for i in 0 1 2; do
- version_part="${version_parts[$i]:-0}"
- minimum_part="${minimum_parts[$i]:-0}"
- version_part="${version_part//[^0-9]/}"
- minimum_part="${minimum_part//[^0-9]/}"
- version_part="${version_part:-0}"
- minimum_part="${minimum_part:-0}"
-
- if ((10#$version_part > 10#$minimum_part)); then
- return 0
- fi
- if ((10#$version_part < 10#$minimum_part)); then
- return 1
- fi
- done
-
- return 0
-}
-
check_podman_compose_version() {
local pc_version
@@ -142,14 +111,6 @@ check_podman_compose_version() {
# podman-compose version; target the compose line explicitly.
pc_version=$(podman-compose --version 2>&1 | grep -i 'podman-compose version' | awk '{print $NF}' || true)
info "podman-compose ${pc_version:-unknown} found"
-
- # 1.6.0 is the first release that resolves nested ${VAR:-${OTHER:-x}}
- # interpolation. Below it, FRONTEND_URL is handed to the containers with the
- # inner ${FRONTEND_PORT:-3000} left as literal text, which silently breaks
- # CORS, passkeys, and the OAuth callbacks.
- if [ -n "$pc_version" ] && ! version_at_least "$pc_version" "1.6.0"; then
- warn "podman-compose $pc_version is old. Upgrade to >= 1.6.0: earlier versions leave FRONTEND_URL unresolved and break login callbacks."
- fi
}
resolve_compose_command() {