tfrere commited on
Commit
2c8e1bd
·
1 Parent(s): 855b7ce

update fast api endpoint

Browse files
frontend/server.js CHANGED
@@ -13,9 +13,7 @@ const apiPort = process.env.INTERNAL_API_PORT || 7861;
13
  const isProduction = process.env.NODE_ENV === "production";
14
 
15
  // Get the backend URL from environment or use localhost in development
16
- const backendUrl = isProduction
17
- ? `http://127.0.0.1:${apiPort}` // Même conteneur en production (IPv4 explicite)
18
- : `http://127.0.0.1:${apiPort}`; // URL de développement
19
 
20
  // Enable CORS for all routes
21
  app.use(cors());
 
13
  const isProduction = process.env.NODE_ENV === "production";
14
 
15
  // Get the backend URL from environment or use localhost in development
16
+ const backendUrl = `http://127.0.0.1:${apiPort}`; // Pour production et développement
 
 
17
 
18
  // Enable CORS for all routes
19
  app.use(cors());
frontend/src/components/BenchmarkCreateForm.jsx CHANGED
@@ -16,6 +16,7 @@ import AutoFixHighIcon from "@mui/icons-material/AutoFixHigh";
16
  import AuthContainer from "./shared/AuthContainer";
17
  import { useThemeMode } from "../hooks/useThemeMode";
18
  import getTheme from "../config/theme";
 
19
 
20
  /**
21
  * Component to display a stepper with three steps: Login, Upload File, and Generate
@@ -121,7 +122,7 @@ function BenchmarkCreateForm({ onStartGeneration }) {
121
  const formData = new FormData();
122
  formData.append("file", file);
123
 
124
- const response = await fetch("http://localhost:3001/upload", {
125
  method: "POST",
126
  body: formData,
127
  });
 
16
  import AuthContainer from "./shared/AuthContainer";
17
  import { useThemeMode } from "../hooks/useThemeMode";
18
  import getTheme from "../config/theme";
19
+ import API_CONFIG from "../config/api";
20
 
21
  /**
22
  * Component to display a stepper with three steps: Login, Upload File, and Generate
 
122
  const formData = new FormData();
123
  formData.append("file", file);
124
 
125
+ const response = await fetch(`${API_CONFIG.BASE_URL}/upload`, {
126
  method: "POST",
127
  body: formData,
128
  });
frontend/src/config/api.js CHANGED
@@ -1,11 +1,9 @@
1
  // API Configuration
2
  const API_CONFIG = {
3
- // Use the current origin in production (Hugging Face Spaces)
4
- // Fallback to localhost in development
5
- BASE_URL:
6
- process.env.REACT_APP_NODE_ENV === "production"
7
- ? window.location.origin
8
- : "http://localhost:3001",
9
  };
10
 
11
  export default API_CONFIG;
 
1
  // API Configuration
2
  const API_CONFIG = {
3
+ // Use the current origin in production and development
4
+ // This ensures requests are always routed through the Express server
5
+ // which will proxy them to the backend
6
+ BASE_URL: window.location.origin,
 
 
7
  };
8
 
9
  export default API_CONFIG;