fix(deploy): unify backend URL policy

This commit is contained in:
2026-07-12 00:54:39 +02:00
parent a3a266fd81
commit ebdd3aa2c5
10 changed files with 138 additions and 20 deletions
+4 -13
View File
@@ -2,19 +2,10 @@
set -eu
backend_base_url=${BACKEND_BASE_URL-/api}
case "$backend_base_url" in
""|/|/api|/api/) ;;
http://*|https://*)
if printf '%s' "$backend_base_url" | grep -Eq '[[:space:]]|^https?://[^/]*@'; then
echo "Invalid BACKEND_BASE_URL: credentials and whitespace are not allowed" >&2
exit 2
fi
;;
*)
echo "Invalid BACKEND_BASE_URL: use empty/root, /api, or an absolute http(s) URL" >&2
exit 2
;;
esac
if ! /usr/local/bin/validate-backend-url "$backend_base_url"; then
echo "Invalid BACKEND_BASE_URL: use empty/root, /api, or a valid http(s) base without credentials, query, or fragment" >&2
exit 2
fi
runtime_config=$(jq -cn --arg backend_base_url "$backend_base_url" \
'{backendBaseUrl: $backend_base_url}')
printf 'window.__THOTHII_CONFIG__ = %s;\n' "$runtime_config" \