JTh34 commited on
Commit
5814eba
·
1 Parent(s): ea36055

🚀 Déploiement automatique RAG CHU 2025-06-30 18:44:16

Browse files
Files changed (1) hide show
  1. frontend/src/App.js +14 -4
frontend/src/App.js CHANGED
@@ -13,10 +13,20 @@ function App() {
13
 
14
  // Initialisation du WebSocket
15
  useEffect(() => {
16
- const connectWebSocket = () => {
17
- const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
18
- // Frontend sur port 3000, backend sur port 8000
19
- const wsUrl = `${protocol}//localhost:8000/ws`;
 
 
 
 
 
 
 
 
 
 
20
 
21
  const websocket = new WebSocket(wsUrl);
22
 
 
13
 
14
  // Initialisation du WebSocket
15
  useEffect(() => {
16
+ const connectWebSocket = () => {
17
+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
18
+
19
+ // Détection automatique de l'environnement
20
+ let wsUrl;
21
+ if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
22
+ // Développement local : frontend port 3000, backend port 8000
23
+ wsUrl = `${protocol}//localhost:8000/ws`;
24
+ } else {
25
+ // Production (HF Spaces) : même domaine, port 7860
26
+ wsUrl = `${protocol}//${window.location.host}/ws`;
27
+ }
28
+
29
+ console.log('Tentative de connexion WebSocket:', wsUrl);
30
 
31
  const websocket = new WebSocket(wsUrl);
32