#!/bin/bash # Portal Client Setup Script # This script helps set up the portal client with the correct API key configuration set -e echo "🏠 Portal Client Setup" echo "=====================" # Check if we're in the right directory if [ ! -f "Cargo.toml" ] || [ ! -f "index.html" ]; then echo "❌ Error: Please run this script from the portal directory" exit 1 fi # Check if portal-server is configured if [ ! -f "../portal-server/.env" ]; then echo "⚠️ Warning: Portal server .env file not found" echo " Please set up the portal-server first:" echo " cd ../portal-server && cp .env.example .env" echo " Then edit the .env file with your API keys" echo "" fi # Create .env file if it doesn't exist if [ ! -f ".env" ]; then echo "📝 Creating .env file..." cat > .env << EOF # Portal Client Configuration # This file configures the frontend portal app # API Key for portal-server authentication # This must match one of the API_KEYS in the portal-server .env file PORTAL_API_KEY=dev_key_123 # Optional: Override server URL (defaults to http://127.0.0.1:3001) # PORTAL_SERVER_URL=http://localhost:3001 EOF echo "✅ Created .env file with default API key" else echo "✅ .env file already exists" fi # Check if trunk is installed if ! command -v trunk &> /dev/null; then echo "📦 Installing trunk..." cargo install trunk echo "✅ Trunk installed" else echo "✅ Trunk is already installed" fi # Check if wasm32 target is installed if ! rustup target list --installed | grep -q "wasm32-unknown-unknown"; then echo "🎯 Adding wasm32 target..." rustup target add wasm32-unknown-unknown echo "✅ WASM target added" else echo "✅ WASM target is already installed" fi echo "" echo "🎉 Setup complete!" echo "" echo "Next steps:" echo "1. Make sure portal-server is running:" echo " cd ../portal-server && cargo run -- --from-env --verbose" echo "" echo "2. Start the portal client:" echo " source .env && trunk serve" echo "" echo "3. Open your browser to:" echo " http://127.0.0.1:8080" echo "" echo "📚 For troubleshooting, see README.md"