From 88498d3887f457ebcaea4d92a24e6d89f6726a6d Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 15 Apr 2024 21:08:56 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Reordered=20endpoint=20priority=20i?= =?UTF-8?q?n=20server=20entrypoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index 76c48f9d..fa787441 100644 --- a/server.js +++ b/server.js @@ -74,13 +74,8 @@ const method = (m, mw) => (req, res, next) => (req.method === m ? mw(req, res, n const app = express() // Load SSL redirection middleware .use(sslServer.middleware) - // Serves up static files - .use(express.static(path.join(__dirname, 'dist'))) - .use(express.static(path.join(__dirname, process.env.USER_DATA_DIR || 'user-data'))) - .use(express.static(path.join(__dirname, 'public'), { index: 'initialization.html' })) // Load middlewares for parsing JSON, and supporting HTML5 history routing .use(express.json({ limit: '1mb' })) - .use(history()) // GET endpoint to run status of a given URL with GET request .use(ENDPOINTS.statusCheck, (req, res) => { try { @@ -136,6 +131,11 @@ const app = express() res.end(JSON.stringify({ success: false, message: e })); } }) + // Serves up static files + .use(express.static(path.join(__dirname, 'dist'))) + .use(express.static(path.join(__dirname, process.env.USER_DATA_DIR || 'user-data'))) + .use(express.static(path.join(__dirname, 'public'), { index: 'initialization.html' })) + .use(history()) // 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'));