Fix auth gate — protect index.html behind login
This commit is contained in:
@@ -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}`));
|
||||||
|
|||||||
Reference in New Issue
Block a user