========================================
FAMILY HUB - NETWORK ACCESS GUIDE
========================================

🌐 ACCESSING FROM OTHER PCs ON YOUR NETWORK

Your Family Hub can be accessed from any device on your local network
(other computers, tablets, phones, etc.)

========================================
QUICK SETUP (3 STEPS)
========================================

STEP 1: Find Your Server IP Address
------------------------------------
Run this script:
   D:\Hosted\familyhub\get_network_ip.bat

It will show your IP address (e.g., 10.0.0.127 or 192.168.1.100)


STEP 2: Update Frontend Configuration
------------------------------------
Edit: D:\Hosted\familyhub\frontend\.env

Change this line:
   VITE_API_URL=http://localhost:8001

To your network IP:
   VITE_API_URL=http://YOUR_IP:8001

Example:
   VITE_API_URL=http://10.0.0.127:8001


STEP 3: Restart Frontend
------------------------------------
Stop the frontend (Ctrl+C) and restart:
   cd D:\Hosted\familyhub\frontend
   npm run dev


========================================
FIREWALL CONFIGURATION (IMPORTANT!)
========================================

Windows Firewall must allow incoming connections on ports:
- Port 8001 (Backend API)
- Port 5173 (Frontend Web)

AUTOMATIC (Recommended):
-----------------------
Run PowerShell as Administrator and paste:

New-NetFirewallRule -DisplayName "Family Hub Backend" -Direction Inbound -Protocol TCP -LocalPort 8001 -Action Allow
New-NetFirewallRule -DisplayName "Family Hub Frontend" -Direction Inbound -Protocol TCP -LocalPort 5173 -Action Allow

OR MANUAL:
---------
1. Open Windows Defender Firewall
2. Click "Advanced settings"
3. Click "Inbound Rules" > "New Rule"
4. Select "Port" > Next
5. TCP, Specific ports: 8001 > Next
6. Allow the connection > Next
7. All profiles checked > Next
8. Name: "Family Hub Backend" > Finish
9. Repeat for port 5173 (Frontend)


========================================
ACCESSING FROM OTHER DEVICES
========================================

Once configured, from any device on your network:

1. Open a web browser
2. Go to: http://YOUR_IP:5173
   (Replace YOUR_IP with your server's IP address)
3. Login with: jess / password123


========================================
TROUBLESHOOTING
========================================

❌ "Cannot connect" error:
   - Make sure both backend AND frontend are running
   - Check firewall rules are created
   - Ping the server IP from other device

❌ "CORS error" in browser:
   - Backend .env should have: ALLOWED_ORIGINS=*
   - Restart backend after changing .env

❌ "Invalid username or password":
   - Check frontend .env has correct VITE_API_URL
   - Make sure backend is running on port 8001
   - Try: http://YOUR_IP:8001/health in browser


========================================
CURRENT CONFIGURATION
========================================

✅ Backend: Already configured for network access
   - Listening on 0.0.0.0:8001 (all interfaces)
   - CORS allows all origins (ALLOWED_ORIGINS=*)

❌ Frontend: Needs YOUR_IP configuration
   - Update frontend\.env with your IP
   - Restart frontend after update

❌ Firewall: Needs rules for ports 8001 and 5173
   - Run PowerShell commands above (as Administrator)


========================================
SECURITY NOTE
========================================

⚠️ ALLOWED_ORIGINS=* allows ANY website to connect
   This is fine for local network development
   For production, specify exact domains:
   ALLOWED_ORIGINS=https://familyhub.yourdomain.com

========================================
