Fix: Build-Info über API statt Build-Zeit - korrekte Version/Channel-Anzeige zur Runtime

This commit is contained in:
vibe-bot 2025-08-09 16:07:52 +02:00
parent c44d9b7f87
commit 8662a5fbc0
2 changed files with 18 additions and 8 deletions

View file

@ -333,7 +333,14 @@ app.use(express.json());
app.use(cors());
app.get('/api/health', (_req: Request, res: Response) => {
res.json({ ok: true, totalPlays: persistedState.totalPlays ?? 0 });
res.json({
ok: true,
totalPlays: persistedState.totalPlays ?? 0,
buildInfo: {
version: process.env.VITE_APP_VERSION || '1.0.0',
channel: process.env.VITE_BUILD_CHANNEL || 'stable'
}
});
});
// --- Admin Auth ---

View file

@ -30,6 +30,7 @@ export default function App() {
const [chaosMode, setChaosMode] = useState<boolean>(false);
const chaosTimeoutRef = useRef<number | null>(null);
const chaosModeRef = useRef<boolean>(false);
const [buildInfo, setBuildInfo] = useState<{version: string, channel: string}>({version: '1.0.0', channel: 'stable'});
useEffect(() => { chaosModeRef.current = chaosMode; }, [chaosMode]);
useEffect(() => {
@ -46,11 +47,12 @@ export default function App() {
} catch (e: any) {
setError(e?.message || 'Fehler beim Laden der Channels');
}
try { setIsAdmin(await adminStatus()); } catch {}
try {
const h = await fetch('/api/health').then(r => r.json()).catch(() => null);
if (h && typeof h.totalPlays === 'number') setTotalPlays(h.totalPlays);
} catch {}
try { setIsAdmin(await adminStatus()); } catch {}
try {
const h = await fetch('/api/health').then(r => r.json()).catch(() => null);
if (h && typeof h.totalPlays === 'number') setTotalPlays(h.totalPlays);
if (h && h.buildInfo) setBuildInfo(h.buildInfo);
} catch {}
})();
}, []);
@ -115,6 +117,7 @@ export default function App() {
try {
const h = await fetch('/api/health').then(r => r.json()).catch(() => null);
if (h && typeof h.totalPlays === 'number') setTotalPlays(h.totalPlays);
if (h && h.buildInfo) setBuildInfo(h.buildInfo);
} catch {}
};
@ -255,8 +258,8 @@ export default function App() {
<h1 className="text-4xl font-bold">
Jukebox 420
<div className="text-sm font-normal mt-1 opacity-70">
v{import.meta.env.VITE_APP_VERSION || '1.0.0'}
{import.meta.env.VITE_BUILD_CHANNEL === 'nightly' && (
v{buildInfo.version}
{buildInfo.channel === 'nightly' && (
<span className="ml-2" style={{ color: '#ff4d4f' }}> Nightly</span>
)}
</div>