Fix auth gate — protect index.html behind login

This commit is contained in:
Etienne Delvarre
2026-05-28 13:49:14 +02:00
parent 50d5ac518d
commit 1c28953394
+5 -5
View File
@@ -142,11 +142,8 @@ app.post('/api/reorder', requireAuth, async (req, res) => {
} }
}); });
// Static files // Auth gate — redirect to login page if not authenticated
app.use(express.static(path.join(__dirname, 'public'))); app.get('/', (req, res) => {
// SPA fallback
app.get('*', (req, res) => {
if (isAuth(req)) { if (isAuth(req)) {
res.sendFile(path.join(__dirname, 'public', 'index.html')); res.sendFile(path.join(__dirname, 'public', 'index.html'));
} else { } else {
@@ -154,4 +151,7 @@ app.get('*', (req, res) => {
} }
}); });
// Static files (login.html is public, index.html is gated above)
app.use(express.static(path.join(__dirname, 'public'), { index: false }));
app.listen(PORT, () => console.log(`TdB RdB — port ${PORT}`)); app.listen(PORT, () => console.log(`TdB RdB — port ${PORT}`));