#!/bin/sh # Regenerate the SPA's runtime config from the environment at container start. # Lets one prebuilt image target any Honcho backend without a rebuild. # OPENCONCHO_DEFAULT_HONCHO_URL — absolute URL, "same-origin", or empty. # Runs from /docker-entrypoint.d before nginx starts. Requires the html dir to # be writable (default); skip or bind-mount config.js when running --read-only. set -eu cat > /usr/share/nginx/html/config.js < "$ALLOWLIST_CONF" else { printf 'map $http_x_honcho_upstream $allow_upstream {\n' printf ' default 0;\n' IFS=',' for host in $OPENCONCHO_UPSTREAM_ALLOWLIST; do host=$(printf '%s' "$host" | tr -d ' ') [ -z "$host" ] && continue esc=$(printf '%s' "$host" | sed -e 's/[.]/\\./g' -e 's#[*]#[^/]*#g') printf ' "~^https?://%s(:[0-9]+)?(/.*)?$" 1;\n' "$esc" done printf '}\n' } > "$ALLOWLIST_CONF" fi