From 9532cd56db0bfc345510f0a99bb83228957c6bab Mon Sep 17 00:00:00 2001 From: Chris Hondl Date: Fri, 17 Jul 2026 09:52:03 -0700 Subject: [PATCH] fix: make BACKEND_URL env-configurable for single-container deploys The ETL self-trigger (update_curr_year_background, the freshness-ping probe) HTTP-calls BACKEND_URL to reach the data router. Hardcoded to upstream api.statbotics.io under PROD, a single-container deploy that serves all routers from one service (e.g. a staging mirror) sent its self-trigger to the wrong host and never ran ingestion. Read BACKEND_URL from env with the original default as fallback; the deploy sets it to the service's own URL. Verified on the staging mirror: with BACKEND_URL set to the mirror's own API, page-view pings now drive live ingestion (2026iri caught up to TBA in real time). --- backend/src/constants.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/src/constants.py b/backend/src/constants.py index 3e07f453..fd8d73c8 100644 --- a/backend/src/constants.py +++ b/backend/src/constants.py @@ -6,7 +6,15 @@ PROD = os.getenv("PROD", "False") == "True" # 8001 emulates the data server -BACKEND_URL = "https://api.statbotics.io" if PROD else "http://localhost:8001" +# The ETL self-trigger (update_curr_year_background and the freshness-ping probe) +# HTTP-calls BACKEND_URL to reach the data router. When the data router runs as a +# separate service the default is right, but a single-container deploy (e.g. a +# staging mirror serving all routers from one service) must point BACKEND_URL at +# its OWN backend, or the self-trigger hits the wrong host and ingestion never +# runs. Read it from the environment, falling back to the original default. +BACKEND_URL = os.getenv("BACKEND_URL") or ( + "https://api.statbotics.io" if PROD else "http://localhost:8001" +) # DB