#!/usr/bin/env bash set -euo pipefail FRONTEND_URL="${1:-http://localhost:1202}" BACKEND_HEALTH_URL="${2:-}" API_URL="${FRONTEND_URL%/}/api/v1/projects" if ! command -v curl >/dev/null 2>&1; then echo "curl is required for browser runtime verification" >&2 exit 1 fi echo "== GeoIntel browser runtime verification ==" echo "Frontend: ${FRONTEND_URL}" echo "API through frontend proxy: ${API_URL}" frontend_status="$(curl -fsS -o /dev/null -w "%{http_code}" "${FRONTEND_URL}")" if [ "${frontend_status}" != "200" ]; then echo "Frontend returned HTTP ${frontend_status}, expected 200" >&2 exit 1 fi api_response="$(curl -fsS "${API_URL}")" case "${api_response}" in *"&2 echo "Rebuild/restart the frontend container so Vite loads the /api proxy config." >&2 exit 1 ;; esac if ! printf '%s' "${api_response}" | grep -q '"data"'; then echo "API response does not look like the canonical GeoIntel envelope:" >&2 printf '%s\n' "${api_response}" >&2 exit 1 fi if [ -n "${BACKEND_HEALTH_URL}" ]; then echo "Backend health: ${BACKEND_HEALTH_URL}" backend_health="$(curl -fsS "${BACKEND_HEALTH_URL}")" if ! printf '%s' "${backend_health}" | grep -q '"status":"ok"'; then echo "Backend health response is not healthy:" >&2 printf '%s\n' "${backend_health}" >&2 exit 1 fi fi echo "Browser runtime verification passed"