mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
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
This commit is contained in:
15
default/public/error/url-not-found.html
Normal file
15
default/public/error/url-not-found.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Not found</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Not found</h1>
|
||||||
|
<p>
|
||||||
|
The requested URL was not found on this server.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -615,6 +615,12 @@ app.use('/api/backends/scale-alt', scaleAltRouter);
|
|||||||
app.use('/api/speech', speechRouter);
|
app.use('/api/speech', speechRouter);
|
||||||
app.use('/api/azure', azureRouter);
|
app.use('/api/azure', azureRouter);
|
||||||
|
|
||||||
|
// If all other middlewares fail, send 404 error.
|
||||||
|
const notFoundWebpage = fs.readFileSync('./public/error/url-not-found.html', { encoding: 'utf-8' });
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
res.status(404).send(notFoundWebpage);
|
||||||
|
});
|
||||||
|
|
||||||
const tavernUrlV6 = new URL(
|
const tavernUrlV6 = new URL(
|
||||||
(cliArguments.ssl ? 'https://' : 'http://') +
|
(cliArguments.ssl ? 'https://' : 'http://') +
|
||||||
(listen ? '[::]' : '[::1]') +
|
(listen ? '[::]' : '[::1]') +
|
||||||
|
Reference in New Issue
Block a user