docker again

This commit is contained in:
salvacybersec
2025-11-11 07:31:43 +03:00
parent 8ddd6a983f
commit 9062a8d7e0
8 changed files with 441 additions and 2 deletions

View File

@@ -54,8 +54,14 @@ app.updateCorsSettings = updateCorsFromSettings;
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Serve static files (landing page)
app.use(express.static('src/public'));
// Serve static files (landing page and frontend build)
const path = require('path');
app.use(express.static(path.join(__dirname, 'public')));
// Serve landing page at /landing route
app.get('/landing', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'landing.html'));
});
// Session middleware
app.use(session(sessionConfig));
@@ -93,6 +99,23 @@ app.use('/api/stats', require('./routes/stats.routes'));
// Public tracking route (no rate limit on this specific route)
app.use('/t', require('./routes/tracking.routes'));
// Serve frontend SPA (must be after API routes)
app.get('*', (req, res, next) => {
// Skip if it's an API route, tracking route, or landing page
if (req.path.startsWith('/api') || req.path.startsWith('/t') || req.path.startsWith('/landing') || req.path.startsWith('/health')) {
return next();
}
// Serve frontend index.html for all other routes
const frontendPath = path.join(__dirname, 'public', 'dist', 'index.html');
res.sendFile(frontendPath, (err) => {
if (err) {
// If frontend build doesn't exist, return 404
next();
}
});
});
// 404 handler
app.use((req, res) => {
res.status(404).json({