chane335 commited on
Commit
14fcaac
·
verified ·
1 Parent(s): 643cb67

Upload dashboard/src/App.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. dashboard/src/App.jsx +11 -1
dashboard/src/App.jsx CHANGED
@@ -2,7 +2,17 @@ import React, { useEffect, useMemo, useState } from 'react';
2
  import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
3
  import DecisionGraph from './DecisionGraph';
4
 
5
- const API_URL = 'http://localhost:5000/api/state';
 
 
 
 
 
 
 
 
 
 
6
 
7
  function normalizeRecentActions(actions = []) {
8
  return actions
 
2
  import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
3
  import DecisionGraph from './DecisionGraph';
4
 
5
+ const API_URL = (() => {
6
+ // Prefer explicit override via ?api=... query param or env var
7
+ const q = new URLSearchParams(window.location.search);
8
+ const override = q.get('api');
9
+ if (override) return override.replace(/\/$/, '') + '/api/state';
10
+ // If the dashboard is served from an HF Space, connect to the same origin
11
+ if (window.location.hostname.endsWith('.hf.space')) {
12
+ return window.location.origin + '/api/state';
13
+ }
14
+ return 'http://localhost:5000/api/state';
15
+ })();
16
 
17
  function normalizeRecentActions(actions = []) {
18
  return actions