Generate random VITE_DEV_API_TOKEN in dev.sh, validate Bearer token in shared server/dev-auth.ts middleware. Applied to all Vite plugins (fs, dev-chats, rss, web-search, tmdb, music-search) and claude-proxy. Client-side uses apiFetch() wrapper to attach the token automatically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
952 B
Bash
Executable File
39 lines
952 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Start Claude proxy and Vite dev server together.
|
|
# Both are killed when either exits or when this script receives SIGINT/SIGTERM.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
APP_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
cd "$APP_DIR"
|
|
|
|
# Generate a dev API token if not already set
|
|
if [ -z "$VITE_DEV_API_TOKEN" ]; then
|
|
export VITE_DEV_API_TOKEN=$(openssl rand -hex 16)
|
|
fi
|
|
|
|
cleanup() {
|
|
kill 0 2>/dev/null || true
|
|
wait 2>/dev/null || true
|
|
}
|
|
trap cleanup EXIT INT TERM
|
|
|
|
# Use local node_modules binaries
|
|
BIN="$APP_DIR/node_modules/.bin"
|
|
|
|
# Start Claude proxy in background (skip gracefully if already running on :3141)
|
|
if lsof -ti:3141 > /dev/null 2>&1; then
|
|
echo " Claude proxy already running on :3141 — skipping"
|
|
else
|
|
"$BIN/tsx" server/claude-proxy.ts &
|
|
sleep 0.3
|
|
fi
|
|
|
|
# Start Vite dev server in background
|
|
"$BIN/vite" --host &
|
|
|
|
# Wait for all background jobs (compatible with bash 3.2 on macOS)
|
|
wait
|