nice-bill commited on
Commit
5e00ba0
·
1 Parent(s): 8f45410

Frontend: Auto-append /api to URL

Browse files
Files changed (2) hide show
  1. frontend/.env.example +1 -1
  2. frontend/src/App.jsx +5 -1
frontend/.env.example CHANGED
@@ -1,2 +1,2 @@
1
- # Backend API URL (when deploying separately)
2
  VITE_API_URL=https://nice-bill-agent-arena.hf.space
 
1
+ # Backend API URL (without /api suffix - code adds it automatically)
2
  VITE_API_URL=https://nice-bill-agent-arena.hf.space
frontend/src/App.jsx CHANGED
@@ -1,7 +1,11 @@
1
  import { useState, useEffect } from 'react'
2
  import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts'
3
 
4
- const API_BASE = import.meta.env.VITE_API_URL || '/api'
 
 
 
 
5
 
6
  function App() {
7
  const [runs, setRuns] = useState([])
 
1
  import { useState, useEffect } from 'react'
2
  import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts'
3
 
4
+ const getApiBase = () => {
5
+ const url = import.meta.env.VITE_API_URL || ''
6
+ return url.endsWith('/api') ? url : url + '/api'
7
+ }
8
+ const API_BASE = getApiBase()
9
 
10
  function App() {
11
  const [runs, setRuns] = useState([])