add 404 error-handling to server This is all that seems necessary according to Express? Admittedly my first time using it. https://expressjs.com/en/starter/faq.html#how-do-i-handle-404-responses
Signed| @@ -0,0 +1,15 @@ | ||
| 1 | +<!DOCTYPE html> | |
| 2 | +<html> | |
| 3 | + | |
| 4 | +<head> | |
| 5 | + <title>Not found</title> | |
| 6 | +</head> | |
| 7 | + | |
| 8 | +<body> | |
| 9 | + <h1>Not found</h1> | |
| 10 | + <p> | |
| 11 | + The requested URL was not found on this server. | |
| 12 | + </p> | |
| 13 | +</body> | |
| 14 | + | |
| 15 | +</html> | |
| @@ -615,6 +615,12 @@ app.use('/api/backends/scale-alt', scaleAltRouter); | ||
| 615 | 615 | app.use('/api/speech', speechRouter); |
| 616 | 616 | app.use('/api/azure', azureRouter); |
| 617 | 617 | |
| 618 | +// If all other middlewares fail, send 404 error. | |
| 619 | +const notFoundWebpage = fs.readFileSync('./public/error/url-not-found.html', { encoding: 'utf-8' }); | |
| 620 | +app.use((req, res, next) => { | |
| 621 | + res.status(404).send(notFoundWebpage); | |
| 622 | +}); | |
| 623 | + | |
| 618 | 624 | const tavernUrlV6 = new URL( |
| 619 | 625 | (cliArguments.ssl ? 'https://' : 'http://') + |
| 620 | 626 | (listen ? '[::]' : '[::1]') + |