@echo off
echo 🔧 Fixing server issue...

REM Kill process on port 8080 specifically
echo 🛑 Stopping server on port 8080...
for /f "tokens=5" %%a in ('netstat -aon ^| findstr ":8080 "') do (
    echo Killing process %%a
    taskkill /F /PID %%a 2>nul
)

REM Kill all Node processes just in case
echo 🛑 Stopping all Node.js processes...
taskkill /F /IM node.exe /T 2>nul

REM Wait a moment
echo ⏳ Waiting...
timeout /t 3 /nobreak >nul

REM Start the correct server
echo 🚀 Starting correct server...
cd /d "%~dp0"
echo Working directory: %CD%
echo Starting: node server.js
node server.js

pause