Skip to content

Add /api/health endpoint to check server status 馃彞#328

Description

@anoopcodehack

Add /api/health endpoint to check server status 馃彞

File: server/index.js

No way to check if the backend is running
without hitting a real route 馃拃 fr!!

Fix: add health check route:
app.get('/api/health', (req, res) => {
res.json({
status: 'ok',
uptime: process.uptime(),
timestamp: new Date().toISOString(),
mongodb: mongoose.connection.readyState === 1
? 'connected' : 'disconnected'
})
})

~8 lines! Super useful for deployment!!
Vercel/Render can ping this to check
if server is alive 馃敟
No frontend changes needed 馃幆

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions