From 27995f850018297bd2a342e4ef79a5dc0055f0ab Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Wed, 28 Feb 2024 11:57:25 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=94=20Use=20a=20404=20status=20code=20?= =?UTF-8?q?if=20page=20not=20found=20(fixes=20#1136)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 3920f748..1a7b2c9e 100644 --- a/server.js +++ b/server.js @@ -122,8 +122,10 @@ const app = express() res.end(JSON.stringify({ success: false, message: e })); } }) - // GET fallback endpoint - .get('*', (req, res) => res.sendFile(path.join(__dirname, 'dist', 'index.html'))); + // If no other route is matched, serve up the index.html with a 404 status + .use((req, res) => { + res.status(404).sendFile(path.join(__dirname, 'dist', 'index.html')); + }); /* Create HTTP server from app on port, and print welcome message */ http.createServer(app)