Files
family-hub/get_network_ip.bat

65 lines
1.8 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
echo ========================================
echo Family Hub - Network IP Detection
echo ========================================
echo.
echo Detecting your network IP address...
echo.
set "FOUND_IP="
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /c:"IPv4 Address"') do (
set "IP=%%a"
set "IP=!IP:~1!"
REM Skip localhost and APIPA addresses
echo !IP! | findstr /b "127\." >nul
if errorlevel 1 (
echo !IP! | findstr /b "169\.254\." >nul
if errorlevel 1 (
if not "!IP!"=="" (
echo [32mFound Network IP: !IP![0m
set "FOUND_IP=!IP!"
)
)
)
)
echo.
echo ========================================
echo NETWORK ACCESS SETUP
echo ========================================
echo.
if not "!FOUND_IP!"=="" (
echo Your server IP address is: [1m!FOUND_IP![0m
echo.
echo TO ACCESS FROM OTHER PCs:
echo.
echo 1. Update frontend\.env file:
echo VITE_API_URL=http://!FOUND_IP!:8001
echo.
echo 2. Restart frontend after changing .env:
echo cd frontend
echo npm run dev
echo.
echo 3. On other PCs, open browser to:
echo http://!FOUND_IP!:5173
echo.
echo 4. Make sure Windows Firewall allows:
echo - Port 8001 ^(Backend^)
echo - Port 5173 ^(Frontend^)
echo.
echo FIREWALL RULES ^(Run as Administrator^):
echo netsh advfirewall firewall add rule name="Family Hub Backend" dir=in action=allow protocol=TCP localport=8001
echo netsh advfirewall firewall add rule name="Family Hub Frontend" dir=in action=allow protocol=TCP localport=5173
) else (
echo [31mNo network IP address found![0m
echo Make sure you are connected to a network.
)
echo.
echo ========================================
pause