-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-network.ps1
More file actions
57 lines (49 loc) · 2.1 KB
/
Copy pathstart-network.ps1
File metadata and controls
57 lines (49 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Realtime Chat - Network Setup Script
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Realtime Chat - Network Setup" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Find local IP address
Write-Host "Finding your local IP address..." -ForegroundColor Yellow
$ipAddress = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object {
$_.IPAddress -like "192.168.*" -or
$_.IPAddress -like "10.*" -or
$_.IPAddress -like "172.16.*" -or
$_.IPAddress -like "172.17.*" -or
$_.IPAddress -like "172.18.*" -or
$_.IPAddress -like "172.19.*" -or
$_.IPAddress -like "172.2*.*" -or
$_.IPAddress -like "172.3*.*"
} | Select-Object -First 1).IPAddress
if ($ipAddress) {
Write-Host "Your IP address is: $ipAddress" -ForegroundColor Green
Write-Host ""
Write-Host "The app will be accessible at:" -ForegroundColor Yellow
Write-Host " - On this computer: http://localhost:3000" -ForegroundColor White
Write-Host " - On other devices: http://$ipAddress:3000" -ForegroundColor White
Write-Host ""
# Create/update .env.local file
$envFile = "frontend\.env.local"
$envContent = @"
# Network Configuration
# Auto-generated by start-network.ps1
REACT_APP_API_URL=http://$ipAddress:5000/api
REACT_APP_SOCKET_URL=http://$ipAddress:5000
"@
Write-Host "Creating/updating frontend\.env.local..." -ForegroundColor Yellow
Set-Content -Path $envFile -Value $envContent -Force
Write-Host "✓ Configuration updated!" -ForegroundColor Green
Write-Host ""
} else {
Write-Host "⚠ Could not detect IP address. Using localhost." -ForegroundColor Yellow
Write-Host " You can manually set your IP in frontend\.env.local" -ForegroundColor Yellow
Write-Host ""
}
Write-Host "Starting backend server..." -ForegroundColor Yellow
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$PWD\backend'; npm run dev"
Start-Sleep -Seconds 3
Write-Host "Starting frontend server..." -ForegroundColor Yellow
Write-Host ""
$env:HOST = "0.0.0.0"
Set-Location frontend
npm start