#!/bin/bash # ๐Ÿงก OrangeCat - Automatic API Key Updater # This script will open your browser and guide you through updating the API key echo "๐Ÿงก OrangeCat - API Key Updater" echo "===============================" echo "" echo "๐Ÿ” ISSUE IDENTIFIED: Legacy API keys are disabled" echo "โœ… Your Supabase project IS working - just needs fresh API keys" echo "" # Open the Supabase dashboard echo "๐ŸŒ Opening Supabase dashboard..." # Try different browser commands if command -v google-chrome &> /dev/null; then google-chrome "https://app.supabase.com/project/ohkueislstxomdjavyhs/settings/api" & elif command -v firefox &> /dev/null; then firefox "https://app.supabase.com/project/ohkueislstxomdjavyhs/settings/api" & elif command -v chromium-browser &> /dev/null; then chromium-browser "https://app.supabase.com/project/ohkueislstxomdjavyhs/settings/api" & else echo "๐Ÿ“‹ Please manually open: https://app.supabase.com/project/ohkueislstxomdjavyhs/settings/api" fi echo "" echo "๐Ÿ“‹ INSTRUCTIONS:" echo "1. Find the 'Project API keys' table" echo "2. Look for the 'anon' or 'public' key" echo "3. Copy the key (starts with 'eyJ')" echo "4. Paste it below when prompted" echo "" # Prompt for the new API key read -p "๐Ÿ”‘ Paste the fresh anon API key here: " NEW_API_KEY # Validate the key format if [[ $NEW_API_KEY =~ ^eyJ ]]; then echo "โœ… Valid API key format detected" # Create backup cp .env.local .env.local.backup echo "๐Ÿ’พ Backup created: .env.local.backup" # Update the .env.local file sed -i "s/NEXT_PUBLIC_SUPABASE_ANON_KEY=\"[^\"]*\"/NEXT_PUBLIC_SUPABASE_ANON_KEY=\"$NEW_API_KEY\"/" .env.local echo "โœ… Updated .env.local with fresh API key!" echo "" echo "๐Ÿ”„ Restarting development server..." # Kill existing dev server and restart pkill -f "next dev" sleep 2 npm run dev & echo "" echo "๐ŸŽ‰ OrangeCat should now be working!" echo "๐ŸŒ Open: http://localhost:3000" echo "" echo "๐Ÿงช Testing connection..." sleep 5 node test-supabase-connection.js else echo "โŒ Invalid API key format. Keys should start with 'eyJ'" echo "Please try again with the correct key from Supabase dashboard" fi