Reordered endpoint priority in server entrypoint

This commit is contained in:
Alicia Sykes 2024-04-15 21:08:56 +01:00
parent 25e774ca79
commit 88498d3887
1 changed files with 5 additions and 5 deletions

View File

@ -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'));