#!/usr/bin/env sh set -eu app_env="$(printf '%s' "${APP_ENV:-development}" | tr '[:upper:]' '[:lower:]')" if [ -z "${VITE_ORGFRONT_PUBLIC_URL:-}" ] && [ -n "${ORGFRONT_URL:-}" ]; then export VITE_ORGFRONT_PUBLIC_URL="$ORGFRONT_URL" fi if [ -z "${VITE_ORGFRONT_PUBLIC_URL:-}" ] && [ -n "${ORGFRONT_CALLBACK_URLS:-}" ]; then first_orgfront_callback="${ORGFRONT_CALLBACK_URLS%%,*}" case "$first_orgfront_callback" in http://*/auth/callback | https://*/auth/callback) export VITE_ORGFRONT_PUBLIC_URL="${first_orgfront_callback%/auth/callback}" ;; esac fi case "$app_env" in production|prod|stage|staging) mode="production" ;; *) mode="development" ;; esac if [ "${1:-}" = "--print-public-url" ]; then printf '%s\n' "${VITE_ORGFRONT_PUBLIC_URL:-}" exit 0 fi if [ "${1:-}" = "--print-mode" ]; then printf '%s\n' "$mode" exit 0 fi if [ "$mode" = "production" ]; then echo "Running in production mode with Vite preview..." exec sh -c "npm run build && npm run preview -- --host 0.0.0.0 --port 5175" fi echo "Running in development mode..." exec npm run dev -- --host 0.0.0.0 --port 5175