Fix: milestone routes use milestone_code, config check via backend

- Milestone navigation now uses milestone_code instead of numeric id
- MilestoneDetailPage uses milestone.id (numeric) for project-scoped API calls
- App.tsx checks /config/status on backend first, falls back to wizard
- Added milestone_code to Milestone type
- Fixed MilestoneDetailPage to use fetched milestone.id for sub-queries
This commit is contained in:
zhi
2026-03-22 10:06:33 +00:00
parent fd28bb6b6f
commit ba3245b6d7
5 changed files with 36 additions and 15 deletions

View File

@@ -22,6 +22,10 @@ import axios from 'axios'
const WIZARD_PORT = Number(import.meta.env.VITE_WIZARD_PORT) || 18080
const WIZARD_BASE = `http://127.0.0.1:${WIZARD_PORT}`
const getApiBase = () => {
return localStorage.getItem('HF_BACKEND_BASE_URL') || import.meta.env.VITE_API_BASE || 'http://127.0.0.1:8000'
}
type AppState = 'checking' | 'setup' | 'ready'
export default function App() {
@@ -33,6 +37,22 @@ export default function App() {
}, [])
const checkInitialized = async () => {
// First try the backend /config/status endpoint (reads from config volume directly)
try {
const res = await axios.get(`${getApiBase()}/config/status`, { timeout: 5000 })
const cfg = res.data || {}
if (cfg.backend_url) {
localStorage.setItem('HF_BACKEND_BASE_URL', cfg.backend_url)
}
if (cfg.initialized === true) {
setAppState('ready')
return
}
} catch {
// Backend unreachable — fall through to wizard check
}
// Fallback: try the wizard directly (needed during initial setup before backend starts)
try {
const res = await axios.get(`${WIZARD_BASE}/api/v1/config/harborforge.json`, {
timeout: 5000,
@@ -47,7 +67,7 @@ export default function App() {
setAppState('setup')
}
} catch {
// Wizard unreachable or config doesn't exist → setup needed
// Neither backend nor wizard reachable → setup needed
setAppState('setup')
}
}