feat: configuration portable - URLs et devices auto-détectés

Changements pour rendre l'installation portable :

1. Config réseau auto-détectée
   - config.yaml : LIVEKIT_URL = AUTO (au lieu de IP hardcodée)
   - Devices audio : null par défaut (auto-détection)

2. Client .env dynamique
   - Ajout client/.env.example avec documentation
   - VITE_API_URL configurable pour dev/prod

3. Vite config dynamique
   - Utilisation de loadEnv() pour variables d'environnement
   - Proxies configurables via VITE_API_URL et VITE_LIVEKIT_URL

4. Install script amélioré
   - Détection automatique IP réseau au moment install
   - Génération .env client avec IP détectée
   - Messages informatifs avec IP du serveur

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-27 13:14:14 +02:00
parent f2e1a50d6d
commit b35f80fc7c
4 changed files with 76 additions and 17 deletions
+12 -4
View File
@@ -1,7 +1,15 @@
# PTT Live Client - Configuration environnement # Configuration Client PTT Live
# Copiez ce fichier en .env et adaptez selon votre environnement
# URL API serveur (en dev, utilise le proxy Vite) # URL de l'API serveur
# En développement : laissez /api pour utiliser le proxy Vite
# En production : spécifiez l'URL complète du serveur
# Exemples :
# VITE_API_URL=/api # Dev local (via proxy Vite)
# VITE_API_URL=http://192.168.1.100:3000 # Serveur sur réseau local
# VITE_API_URL=https://ptt.example.com # Production avec domaine
VITE_API_URL=/api VITE_API_URL=/api
# Pour production, pointer vers le serveur # URL LiveKit WebSocket (optionnel, normalement auto-détectée)
# VITE_API_URL=https://your-server.com # Ne définir que si vous voulez forcer une URL spécifique
# VITE_LIVEKIT_URL=ws://192.168.1.100:7880
+13 -4
View File
@@ -1,9 +1,17 @@
import { defineConfig } from 'vite'; import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import { VitePWA } from 'vite-plugin-pwa'; import { VitePWA } from 'vite-plugin-pwa';
import fs from 'fs'; import fs from 'fs';
export default defineConfig({ export default defineConfig(({ mode }) => {
// Charger les variables d'environnement
const env = loadEnv(mode, process.cwd(), '');
// Déterminer l'URL de l'API (utilise variable d'environnement ou fallback localhost)
const apiUrl = env.VITE_API_URL || 'http://localhost:3000';
const livekitUrl = env.VITE_LIVEKIT_URL || 'ws://localhost:7880';
return {
plugins: [ plugins: [
react(), react(),
VitePWA({ VitePWA({
@@ -68,12 +76,12 @@ export default defineConfig({
}, },
proxy: { proxy: {
'/api': { '/api': {
target: 'http://192.168.0.146:3000', target: apiUrl.startsWith('/') ? 'http://localhost:3000' : apiUrl,
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '') rewrite: (path) => path.replace(/^\/api/, '')
}, },
'/livekit': { '/livekit': {
target: 'ws://192.168.0.146:7880', target: livekitUrl,
ws: true, ws: true,
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/livekit/, '') rewrite: (path) => path.replace(/^\/livekit/, '')
@@ -84,4 +92,5 @@ export default defineConfig({
outDir: 'dist', outDir: 'dist',
sourcemap: true sourcemap: true
} }
};
}); });
+46 -6
View File
@@ -96,14 +96,30 @@ echo ""
cd .. cd ..
# Créer fichier .env # Détecter l'IP réseau locale
echo "🔑 Génération configuration LiveKit..." echo "🌐 Détection configuration réseau..."
NETWORK_IP=$(ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | head -n 1)
if [ -z "$NETWORK_IP" ]; then
echo -e "${YELLOW}⚠️ IP réseau non détectée, utilisation localhost${NC}"
NETWORK_IP="localhost"
else
echo -e "${GREEN}✅ IP réseau détectée : ${NETWORK_IP}${NC}"
fi
echo ""
# Créer fichier .env serveur
echo "🔑 Génération configuration serveur..."
cat > server/.env << EOF cat > server/.env << EOF
# Configuration PTT Live Server
# Généré automatiquement par install/macos.sh
USE_LOCAL_LIVEKIT=true USE_LOCAL_LIVEKIT=true
# LiveKit Configuration # LiveKit Configuration
LIVEKIT_URL=ws://localhost:7880 # AUTO = détection automatique IP réseau au démarrage
LIVEKIT_URL=AUTO
# En mode --dev, LiveKit utilise ces clés par défaut # En mode --dev, LiveKit utilise ces clés par défaut
LIVEKIT_API_KEY=devkey LIVEKIT_API_KEY=devkey
LIVEKIT_API_SECRET=secret LIVEKIT_API_SECRET=secret
@@ -113,7 +129,23 @@ PORT=3000
NODE_ENV=development NODE_ENV=development
EOF EOF
echo -e "${GREEN}✅ Clés API générées (server/.env)${NC}" echo -e "${GREEN}✅ Configuration serveur générée (server/.env)${NC}"
# Créer fichier .env client
echo "🔑 Génération configuration client..."
cat > client/.env << EOF
# Configuration PTT Live Client
# Généré automatiquement par install/macos.sh
# En développement local, utilise le proxy Vite
VITE_API_URL=/api
# Pour accès réseau (autres devices), décommentez et mettez l'IP du serveur :
# VITE_API_URL=http://${NETWORK_IP}:3000
EOF
echo -e "${GREEN}✅ Configuration client générée (client/.env)${NC}"
echo "" echo ""
# Message final # Message final
@@ -128,7 +160,15 @@ echo ""
echo " 2. Démarrer le client (nouveau terminal) :" echo " 2. Démarrer le client (nouveau terminal) :"
echo " cd client && npm run dev" echo " cd client && npm run dev"
echo "" echo ""
echo " 3. Ouvrir https://localhost:5173 dans votre navigateur" echo " 3. Accéder à l'application :"
echo " • Développement local : https://localhost:5173"
echo " • Depuis autre appareil (WiFi) : https://${NETWORK_IP}:5173"
echo "" echo ""
echo "📖 Documentation : README.md" echo "💡 Configuration réseau :"
echo " IP serveur détectée : ${NETWORK_IP}"
echo " LiveKit URL : AUTO (détection dynamique)"
echo ""
echo "📖 Documentation :"
echo " • README.md - Guide complet"
echo " • README-PORTABLE.md - Déploiement portable"
echo "" echo ""
+5 -3
View File
@@ -4,8 +4,10 @@ audio:
defaultBitrate: 96 defaultBitrate: 96
jitterBufferMs: 40 jitterBufferMs: 40
device: device:
inputDeviceId: Microphone MacBook Pro # Laissez null pour auto-détection du device par défaut
outputDeviceId: Haut-parleurs MacBook Pro # Ou spécifiez le nom exact via l'interface /admin
inputDeviceId: null
outputDeviceId: null
sampleRate: 48000 sampleRate: 48000
routing: routing:
inputToGroup: inputToGroup:
@@ -50,7 +52,7 @@ server:
host: 0.0.0.0 host: 0.0.0.0
port: 3000 port: 3000
livekit: livekit:
url: ws://192.168.0.146:7880 url: AUTO # AUTO = détection automatique IP réseau | ou ws://IP:7880 pour manuel
logging: logging:
level: info # Changez à 'debug' pour voir plus de détails level: info # Changez à 'debug' pour voir plus de détails
logLatency: false logLatency: false