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:
+12
-4
@@ -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
|
||||
|
||||
# Pour production, pointer vers le serveur
|
||||
# VITE_API_URL=https://your-server.com
|
||||
# URL LiveKit WebSocket (optionnel, normalement auto-détectée)
|
||||
# Ne définir que si vous voulez forcer une URL spécifique
|
||||
# VITE_LIVEKIT_URL=ws://192.168.1.100:7880
|
||||
|
||||
+13
-4
@@ -1,9 +1,17 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
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: [
|
||||
react(),
|
||||
VitePWA({
|
||||
@@ -68,12 +76,12 @@ export default defineConfig({
|
||||
},
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://192.168.0.146:3000',
|
||||
target: apiUrl.startsWith('/') ? 'http://localhost:3000' : apiUrl,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
},
|
||||
'/livekit': {
|
||||
target: 'ws://192.168.0.146:7880',
|
||||
target: livekitUrl,
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/livekit/, '')
|
||||
@@ -84,4 +92,5 @@ export default defineConfig({
|
||||
outDir: 'dist',
|
||||
sourcemap: true
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user