Skip to content

Commit

Permalink
redirect to start-page if requested page is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
guFalcon committed Apr 12, 2024
1 parent 7ca22b3 commit a4faf73
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ initKeycloak(app).then(() => {
fs.readFile(filePath, "utf8", (err, data) => {
if (err) {
console.error(`Error reading file ${filePath}`, err);
return next(err);
res.redirect(getStartPage());
return;
}
const reveal = req.query.reveal;
if (reveal) {
Expand Down Expand Up @@ -301,4 +302,7 @@ initKeycloak(app).then(() => {
scanFiles(basePath).then(() => {
app.listen(process.env.NEXT_PUBLIC_PORT, "0.0.0.0");
});

// If file is not found, redirect to the start page.
app.use((_, res) => res.redirect(getStartPage()));
});

0 comments on commit a4faf73

Please sign in to comment.