tfrere commited on
Commit
fd60f38
·
1 Parent(s): 18a01e2

fix repo name in client

Browse files
Files changed (1) hide show
  1. client/src/pages/game/App.jsx +8 -1
client/src/pages/game/App.jsx CHANGED
@@ -22,7 +22,10 @@ import { LAYOUTS } from "../../layouts/config";
22
  import html2canvas from "html2canvas";
23
 
24
  // Get API URL from environment or default to localhost in development
25
- const API_URL = import.meta.env.VITE_API_URL || "http://localhost:8000";
 
 
 
26
 
27
  // Generate a unique client ID
28
  const CLIENT_ID = `client_${Math.random().toString(36).substring(2)}`;
@@ -32,6 +35,10 @@ const api = axios.create({
32
  headers: {
33
  "x-client-id": CLIENT_ID,
34
  },
 
 
 
 
35
  });
36
 
37
  // Function to convert text with ** to Chip elements
 
22
  import html2canvas from "html2canvas";
23
 
24
  // Get API URL from environment or default to localhost in development
25
+ const isHFSpace = window.location.hostname.includes("hf.space");
26
+ const API_URL = isHFSpace
27
+ ? "" // URL relative pour HF Spaces
28
+ : import.meta.env.VITE_API_URL || "http://localhost:8000";
29
 
30
  // Generate a unique client ID
31
  const CLIENT_ID = `client_${Math.random().toString(36).substring(2)}`;
 
35
  headers: {
36
  "x-client-id": CLIENT_ID,
37
  },
38
+ // Ajouter baseURL pour HF Spaces
39
+ ...(isHFSpace && {
40
+ baseURL: window.location.origin,
41
+ }),
42
  });
43
 
44
  // Function to convert text with ** to Chip elements