diff --git a/backend/src/index.ts b/backend/src/index.ts index b3d132a..e6325c5 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -31,6 +31,11 @@ app.use(express.urlencoded({ extended: true, limit: '50mb' })) app.use('/uploads', express.static(UPLOADS_DIR)) // ─── Routes API ─────────────────────────────────────────────────────────────── +// IMPORTANT: health check MUST be before authenticated routers +app.get('/api/health', (_req, res) => { + res.json({ status: 'ok', service: 'shoottracker', ts: new Date().toISOString() }) +}) + app.use('/api/auth', authRouter) app.use('/api/weapons', weaponsRouter) app.use('/api', sessionsRouter) @@ -39,10 +44,6 @@ app.use('/api', miscRouter) app.use('/api', analyzeRouter) app.use('/api/export', exportRouter) -app.get('/api/health', (_req, res) => { - res.json({ status: 'ok', service: 'shoottracker', ts: new Date().toISOString() }) -}) - // ─── Serve Frontend (production) ───────────────────────────────────────────── const publicDir = path.join(__dirname, '..', 'public') if (fs.existsSync(publicDir)) { @@ -54,5 +55,4 @@ if (fs.existsSync(publicDir)) { app.listen(PORT, () => { console.log(`✓ ShootTracker backend → http://localhost:${PORT}`) console.log(` Uploads : ${UPLOADS_DIR}`) - console.log(` AI : ${process.env.AI_SERVICE_URL || 'http://localhost:8000'}`) -}) + console.log(` AI \ No newline at end of file