Spaces:
Sleeping
Sleeping
Frontend: Auto-append /api to URL
Browse files- frontend/.env.example +1 -1
- frontend/src/App.jsx +5 -1
frontend/.env.example
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
# Backend API URL (
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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([])
|