#!/bin/bash # Update .web/env.json with API_URL from environment variable at runtime set -e API_URL="${API_URL:-http://localhost:8000}" # Extract protocol, host, and port from API_URL if [[ "$API_URL" =~ ^(https?://)([^:/]+)(:([0-9]+))? ]]; then PROTOCOL="${BASH_REMATCH[1]}" HOST="${BASH_REMATCH[2]}" PORT="${BASH_REMATCH[4]:-8000}" # Remove trailing slash API_URL="${API_URL%/}" # Update .web/env.json if [ -f "/app/.web/env.json" ]; then # Use Python to properly update JSON python3 <