# Internal Server Migration Complete

## Changes Made

✅ Migrated from ngrok to internal server: `https://192.168.10.10:8080`
✅ Updated OAuth redirect URIs in `credentials.json`
✅ Removed ngrok URL detection code
✅ Configured Flask to bind on `0.0.0.0:8080` (accessible from network)
✅ Added SSL support with self-signed certificates

## Next Steps

### 1. Install pyOpenSSL (Required for SSL)

```powershell
pip install pyOpenSSL
```

### 2. Update Google Cloud Console

Go to: https://console.cloud.google.com/apis/credentials

Update your OAuth 2.0 Client ID:
- **Authorized redirect URIs**: `https://192.168.10.10:8080/oauth2callback`
- **Authorized JavaScript origins**: `https://192.168.10.10:8080`

### 3. Test the Server

Run the app:
```powershell
python app.py
```

Access from:
- Your machine: `https://192.168.10.10:8080`
- Network devices: `https://192.168.10.10:8080`

⚠️ **Initial browser warning**: Self-signed certificates will show a security warning. Click "Advanced" > "Proceed" to continue.

### 4. Production SSL Certificates (Optional)

For production, replace self-signed certificates:

1. Get SSL certificates (from IT or use Let's Encrypt)
2. Place them in the project folder:
   - `cert.pem` (certificate)
   - `key.pem` (private key)

3. Update `app.py` line ~7257:
   ```python
   ssl_context = ('cert.pem', 'key.pem')  # Instead of 'adhoc'
   ```

## Firewall Configuration

Ensure port **8080** is open:

```powershell
# Check if port is listening
netstat -an | findstr :8080

# Open firewall (run as Administrator)
New-NetFirewallRule -DisplayName "Sales Dashboard HTTPS" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow
```

## Troubleshooting

**Cannot access from other devices?**
- Check Windows Firewall allows port 8080
- Verify 192.168.10.10 is your machine's actual IP: `ipconfig`
- Try accessing from your own machine first

**SSL Certificate errors?**
- Expected with self-signed certs - click through the warning
- For production, use real certificates

**OAuth errors?**
- Verify Google Cloud Console has the correct redirect URI
- Clear browser cache and cookies
- Check credentials.json has the right URL

## Rollback to ngrok

If you need to go back:
```powershell
Copy-Item app_backup_20260303_094646.py app.py
```

Then restore the old credentials.json redirect URIs.
