From a3277f352e0e6bf29e3b20ff1fffbbcf8c8fe1b2 Mon Sep 17 00:00:00 2001 From: Daniel Onyejesi Date: Mon, 23 Mar 2026 23:47:50 -0400 Subject: [PATCH] Add proper 404 handling and custom error page Only serve index.html for GET /; all other unknown paths return HTTP 404 with a custom branded error page (stethoscope SVG illustration, matches app design, links back to /). --- public/404.html | 175 ++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 7 +- 2 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 public/404.html diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..4f66bcf --- /dev/null +++ b/public/404.html @@ -0,0 +1,175 @@ + + + + + + 404 – Page Not Found | Pediatric AI Scribe + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + ? + + + + + + + + + +
+ +
+ + Error 404 +
+ +

This page doesn't exist

+

The URL you visited isn't part of Pediatric AI Scribe.
It may have been mistyped or the link is outdated.

+ + + + Back to the app + + + +
+ + diff --git a/server.js b/server.js index 9fcb83e..e28f59d 100644 --- a/server.js +++ b/server.js @@ -155,13 +155,18 @@ app.use('/api', require('./src/routes/memories')); app.use('/api', require('./src/routes/wellVisit')); app.use('/api', require('./src/routes/sickVisit')); -app.get('*', (req, res) => { +app.get('/', (req, res) => { res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); res.setHeader('Pragma', 'no-cache'); res.setHeader('Expires', '0'); res.sendFile(path.join(__dirname, 'public', 'index.html')); }); +// 404 handler — must be last +app.use((req, res) => { + res.status(404).sendFile(path.join(__dirname, 'public', '404.html')); +}); + // Load prompt DB overrides after DB is ready (3s grace period) const PROMPTS = require('./src/utils/prompts'); const db = require('./src/db/database');