A community based topic aggregation platform built on atproto
at main 84 lines 2.3 kB view raw
1#!/bin/bash 2# Web frontend development server runner 3# Starts both Coves backend AND Vite frontend, uses Caddy proxy on port 8080 4# 5# Usage: make run-web (or ./scripts/web-dev-run.sh) 6 7set -a # automatically export all variables 8source .env.dev 9set +a 10 11# Override for web frontend development 12# OAuth callback needs to use the proxy port (8080) for cookie sharing 13# MUST use 127.0.0.1 (not localhost) per RFC 8252 - PDS rejects localhost in redirect_uri 14export APPVIEW_PUBLIC_URL="http://127.0.0.1:8080" 15 16# Resolve paths relative to this script (no hardcoded absolute paths) 17SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 18COVES_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" 19 20# Frontend location (override with KELP_DIR env var) 21# Try coves-frontend first, fall back to kelp for backwards compatibility 22if [ -z "$KELP_DIR" ]; then 23 if [ -d "$COVES_DIR/../coves-frontend" ]; then 24 KELP_DIR="$COVES_DIR/../coves-frontend" 25 else 26 KELP_DIR="$COVES_DIR/../kelp" 27 fi 28fi 29 30# Cleanup function 31cleanup() { 32 echo "" 33 echo "🛑 Shutting down..." 34 # Kill the Vite process if it's running 35 if [ -n "$VITE_PID" ]; then 36 kill $VITE_PID 2>/dev/null 37 wait $VITE_PID 2>/dev/null 38 fi 39 exit 0 40} 41 42# Set up trap for clean shutdown 43trap cleanup SIGINT SIGTERM 44 45echo "🌐 Starting Coves WEB FRONTEND development environment..." 46echo "" 47echo " IS_DEV_ENV: $IS_DEV_ENV" 48echo " PLC_DIRECTORY_URL: $PLC_DIRECTORY_URL" 49echo " APPVIEW_PUBLIC_URL: $APPVIEW_PUBLIC_URL (via Caddy proxy)" 50echo " PDS_URL: $PDS_URL" 51echo " Build tags: dev" 52echo "" 53 54# Check if kelp directory exists 55if [ ! -d "$KELP_DIR" ]; then 56 echo "❌ Frontend directory not found: $KELP_DIR" 57 exit 1 58fi 59 60# Start Vite in background 61echo "🚀 Starting Vite frontend (kelp) on :5173..." 62cd "$KELP_DIR" && pnpm dev & 63VITE_PID=$! 64 65# Give Vite a moment to start 66sleep 2 67 68# Return to Coves directory 69cd "$COVES_DIR" 70 71echo "" 72echo "🚀 Starting Coves backend on :8081..." 73echo "" 74echo " ⚠️ Make sure Caddy proxy is running: make web-proxy" 75echo " 📍 Access your app at: http://localhost:8080" 76echo "" 77echo " Press Ctrl+C to stop both services" 78echo "" 79 80# Run Go server (foreground - will block) 81go run -tags dev ./cmd/server 82 83# If Go server exits, clean up Vite 84cleanup