Spaces:
Running
Running
update client cors and api url
Browse files
client/.env.production
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
|
|
|
|
client/src/config/api.js
CHANGED
@@ -1 +1,19 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Detect if we're running in a HF Space
|
2 |
+
const isHfSpace =
|
3 |
+
window.location.hostname.endsWith(".hf.space") ||
|
4 |
+
window.location !== window.parent.location;
|
5 |
+
|
6 |
+
// Get the base API URL based on the environment
|
7 |
+
const API_BASE_URL = isHfSpace ? "/api" : "http://localhost:3002/api";
|
8 |
+
|
9 |
+
export const API_URLS = {
|
10 |
+
leaderboards: `${API_BASE_URL}/leaderboards`,
|
11 |
+
health: `${API_BASE_URL}/health`,
|
12 |
+
};
|
13 |
+
|
14 |
+
// Export additional environment info
|
15 |
+
export const ENV_INFO = {
|
16 |
+
isHfSpace,
|
17 |
+
};
|
18 |
+
|
19 |
+
export default API_URLS;
|
client/src/pages/LeaderboardPage/LeaderboardPage.jsx
CHANGED
@@ -11,6 +11,7 @@ import Logo from "../../components/Logo/Logo";
|
|
11 |
import PageHeader from "../../components/PageHeader/PageHeader";
|
12 |
import LeaderboardSection from "../../components/LeaderboardSection";
|
13 |
import { alpha } from "@mui/material/styles";
|
|
|
14 |
|
15 |
const LeaderboardPage = () => {
|
16 |
const [leaderboards, setLeaderboards] = useState(null);
|
@@ -18,7 +19,7 @@ const LeaderboardPage = () => {
|
|
18 |
const [arenaOnly, setArenaOnly] = useState(false);
|
19 |
|
20 |
useEffect(() => {
|
21 |
-
fetch(
|
22 |
.then((res) => res.json())
|
23 |
.then((data) => {
|
24 |
const leaderboardsArray = Array.isArray(data)
|
|
|
11 |
import PageHeader from "../../components/PageHeader/PageHeader";
|
12 |
import LeaderboardSection from "../../components/LeaderboardSection";
|
13 |
import { alpha } from "@mui/material/styles";
|
14 |
+
import API_URLS from "../../config/api";
|
15 |
|
16 |
const LeaderboardPage = () => {
|
17 |
const [leaderboards, setLeaderboards] = useState(null);
|
|
|
19 |
const [arenaOnly, setArenaOnly] = useState(false);
|
20 |
|
21 |
useEffect(() => {
|
22 |
+
fetch(API_URLS.leaderboards)
|
23 |
.then((res) => res.json())
|
24 |
.then((data) => {
|
25 |
const leaderboardsArray = Array.isArray(data)
|
server/server.py
CHANGED
@@ -22,6 +22,8 @@ app.add_middleware(
|
|
22 |
allow_origins=[
|
23 |
"http://localhost:5173", # Vite dev server
|
24 |
f"http://localhost:{API_PORT}", # API port
|
|
|
|
|
25 |
],
|
26 |
allow_credentials=True,
|
27 |
allow_methods=["*"],
|
|
|
22 |
allow_origins=[
|
23 |
"http://localhost:5173", # Vite dev server
|
24 |
f"http://localhost:{API_PORT}", # API port
|
25 |
+
"https://huggingface.co", # HF main domain
|
26 |
+
"https://*.hf.space", # HF Spaces domains
|
27 |
],
|
28 |
allow_credentials=True,
|
29 |
allow_methods=["*"],
|