- Fix NODE_ENV=production cookie security issue for local development - Add production API URL configuration (.env.production) - Enable SPA routing with serve -s flag for frontend - Fix React hooks violation in DashboardPage (error #310) - Move useQuery hooks before conditional returns - Rebuild frontend with all fixes applied Resolves dashboard 401 errors, 404 routing issues, and React error #310
69 lines
2.2 KiB
Bash
Executable File
69 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# URL Tracker Tool V2 - Service Startup Script
|
|
# This script starts both API and Frontend services
|
|
|
|
set -e
|
|
|
|
# Environment variables
|
|
export NODE_ENV="development"
|
|
export PORT=3334
|
|
export CORS_ORIGIN="https://urltrackertool.com"
|
|
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/redirect_intelligence_v2?schema=public"
|
|
export JWT_SECRET="J9k2L7mP4nQ8vX3w6Z9c2F5h8K1m4P7r0T3w6Y9b2E5g8J1l4O7q0S3v6Z9c2F5h"
|
|
|
|
# Change to app directory
|
|
cd /root/catch_redirect
|
|
|
|
# Log startup
|
|
echo "$(date): Starting URL Tracker Tool V2 services..." >> /var/log/catch-redirect.log
|
|
|
|
# Kill any existing processes
|
|
pkill -f "node dist/index.js" || true
|
|
pkill -f "npx serve" || true
|
|
sleep 2
|
|
|
|
# Start API service
|
|
echo "$(date): Starting API service on port $PORT..." >> /var/log/catch-redirect.log
|
|
cd /root/catch_redirect/apps/api
|
|
nohup node dist/index.js >> /var/log/catch-redirect-api.log 2>&1 &
|
|
API_PID=$!
|
|
echo "$(date): API service started with PID $API_PID" >> /var/log/catch-redirect.log
|
|
|
|
# Wait for API to be ready
|
|
sleep 5
|
|
|
|
# Start Frontend service
|
|
echo "$(date): Starting Frontend service on port 3000..." >> /var/log/catch-redirect.log
|
|
cd /root/catch_redirect/apps/web
|
|
nohup serve dist -s -l 3000 >> /var/log/catch-redirect-frontend.log 2>&1 &
|
|
FRONTEND_PID=$!
|
|
echo "$(date): Frontend service started with PID $FRONTEND_PID" >> /var/log/catch-redirect.log
|
|
|
|
# Save PIDs for monitoring
|
|
echo "$API_PID" > /var/run/catch-redirect-api.pid
|
|
echo "$FRONTEND_PID" > /var/run/catch-redirect-frontend.pid
|
|
|
|
# Wait and monitor
|
|
sleep 3
|
|
|
|
# Check if services are running
|
|
if curl -s http://localhost:3334/health > /dev/null; then
|
|
echo "$(date): API service health check passed" >> /var/log/catch-redirect.log
|
|
else
|
|
echo "$(date): ERROR - API service health check failed" >> /var/log/catch-redirect.log
|
|
exit 1
|
|
fi
|
|
|
|
if curl -s http://localhost:3000 > /dev/null; then
|
|
echo "$(date): Frontend service health check passed" >> /var/log/catch-redirect.log
|
|
else
|
|
echo "$(date): ERROR - Frontend service health check failed" >> /var/log/catch-redirect.log
|
|
exit 1
|
|
fi
|
|
|
|
echo "$(date): All services started successfully" >> /var/log/catch-redirect.log
|
|
|
|
# Keep the script running to maintain the service
|
|
wait
|