#!/bin/bash
# SmashPoint - Cabo Pickleball Club
# Production server start script

set -e

# Load environment variables
export NEXTAUTH_URL="https://smashpoint.consultoria-as.com"
export NEXT_PUBLIC_APP_URL="https://smashpoint.consultoria-as.com"
export NEXTAUTH_SECRET="xApk6WiZYJZwUpKk6ZlyHoseXqsCSnTmRDqzDdmtRVY="

APP_DIR="/root/Padel/apps/web"
PORT=3000

# Kill any existing server on the port
fuser -k $PORT/tcp 2>/dev/null || true
sleep 2

cd "$APP_DIR"

echo "Starting SmashPoint on port $PORT..."
echo "URL: $NEXTAUTH_URL"

npx next start --port $PORT
