persee-tech commited on
Commit
7ce3d45
·
verified ·
1 Parent(s): 4fdb12c

Update backend/server.py

Browse files
Files changed (1) hide show
  1. backend/server.py +10 -7
backend/server.py CHANGED
@@ -13,7 +13,7 @@ from supabase import create_client, Client
13
 
14
  # --- 1. CONFIGURATION SUPABASE ---
15
  SUPABASE_URL = os.getenv("SUPABASE_URL", "https://gwjrwejdjpctizolfkcz.supabase.co")
16
- SUPABASE_KEY = os.getenv("SUPABASE_KEY") # On récupère la clé secrète des variables d'environnement
17
 
18
  try:
19
  if SUPABASE_KEY:
@@ -24,15 +24,18 @@ try:
24
  except Exception as e:
25
  print(f"❌ Erreur connexion Supabase : {e}")
26
 
27
- # --- 2. CONFIGURATION SOCKET.IO (CORS TOTAL) ---
28
- # On configure le serveur pour tout accepter, sans restriction.
29
- mgr = socketio.AsyncRedisManager(os.environ.get('REDIS_URL', '')) if os.environ.get('REDIS_URL') else None
 
 
 
30
  sio = socketio.AsyncServer(
31
  async_mode='asgi',
32
- cors_allowed_origins='*', # L'étoile magique
33
- logger=True, # Logs activés pour voir les connexions
34
  engineio_logger=True,
35
- always_connect=True # Force la connexion même si le transport est bizarre
36
  )
37
 
38
  app = FastAPI()
 
13
 
14
  # --- 1. CONFIGURATION SUPABASE ---
15
  SUPABASE_URL = os.getenv("SUPABASE_URL", "https://gwjrwejdjpctizolfkcz.supabase.co")
16
+ SUPABASE_KEY = os.getenv("SUPABASE_KEY")
17
 
18
  try:
19
  if SUPABASE_KEY:
 
24
  except Exception as e:
25
  print(f"❌ Erreur connexion Supabase : {e}")
26
 
27
+ # --- 2. CONFIGURATION SOCKET.IO (BYPASS TOTAL) ---
28
+ # Cette fonction force l'acceptation de tout le monde et affiche qui se connecte
29
+ def force_allow_origins(origin, environ, **kwargs):
30
+ print(f"🔍 TENTATIVE CONNEXION DEPUIS : {origin}")
31
+ return True # Retourne toujours VRAI (Autorisé)
32
+
33
  sio = socketio.AsyncServer(
34
  async_mode='asgi',
35
+ cors_allowed_origins=force_allow_origins, # On utilise la fonction au lieu de '*'
36
+ logger=True,
37
  engineio_logger=True,
38
+ always_connect=True
39
  )
40
 
41
  app = FastAPI()