From c87b6105b9386c201cc1683b43149c98fa202d17 Mon Sep 17 00:00:00 2001 From: david akor Date: Tue, 24 Feb 2026 12:54:20 -0800 Subject: [PATCH] feat: Implement global 404 Not Found route handler Closes #14 - Add catch-all route (app.use('*', ...)) at the bottom of route declarations - Return 404 HTTP status for missing endpoints - Return JSON response { error: 'Route not found' } - Ensures frontend can handle missing API endpoints consistently - Add documentation comments for clarity --- server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 05dce14..430dff7 100644 --- a/server.js +++ b/server.js @@ -82,7 +82,8 @@ app.use((err, req, res, next) => { res.status(500).json({ error: 'Something went wrong!' }); }); -// 404 handler +// Global 404 Not Found handler - catches all unmatched routes +// Must be placed after all other route declarations app.use('*', (req, res) => { res.status(404).json({ error: 'Route not found' }); });