fix: move /api/health before auth middleware so Docker healthcheck returns 200
This commit is contained in:
@@ -31,6 +31,11 @@ app.use(express.urlencoded({ extended: true, limit: '50mb' }))
|
|||||||
app.use('/uploads', express.static(UPLOADS_DIR))
|
app.use('/uploads', express.static(UPLOADS_DIR))
|
||||||
|
|
||||||
// ─── Routes API ───────────────────────────────────────────────────────────────
|
// ─── 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/auth', authRouter)
|
||||||
app.use('/api/weapons', weaponsRouter)
|
app.use('/api/weapons', weaponsRouter)
|
||||||
app.use('/api', sessionsRouter)
|
app.use('/api', sessionsRouter)
|
||||||
@@ -39,10 +44,6 @@ app.use('/api', miscRouter)
|
|||||||
app.use('/api', analyzeRouter)
|
app.use('/api', analyzeRouter)
|
||||||
app.use('/api/export', exportRouter)
|
app.use('/api/export', exportRouter)
|
||||||
|
|
||||||
app.get('/api/health', (_req, res) => {
|
|
||||||
res.json({ status: 'ok', service: 'shoottracker', ts: new Date().toISOString() })
|
|
||||||
})
|
|
||||||
|
|
||||||
// ─── Serve Frontend (production) ─────────────────────────────────────────────
|
// ─── Serve Frontend (production) ─────────────────────────────────────────────
|
||||||
const publicDir = path.join(__dirname, '..', 'public')
|
const publicDir = path.join(__dirname, '..', 'public')
|
||||||
if (fs.existsSync(publicDir)) {
|
if (fs.existsSync(publicDir)) {
|
||||||
@@ -54,5 +55,4 @@ if (fs.existsSync(publicDir)) {
|
|||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log(`✓ ShootTracker backend → http://localhost:${PORT}`)
|
console.log(`✓ ShootTracker backend → http://localhost:${PORT}`)
|
||||||
console.log(` Uploads : ${UPLOADS_DIR}`)
|
console.log(` Uploads : ${UPLOADS_DIR}`)
|
||||||
console.log(` AI : ${process.env.AI_SERVICE_URL || 'http://localhost:8000'}`)
|
console.log(` AI
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user