Add single container Docker setup (backend + frontend in one container)
This commit is contained in:
@@ -100,6 +100,23 @@ app.use(express.urlencoded({ extended: true }));
|
||||
// Serve static files (landing page)
|
||||
app.use(express.static('src/public'));
|
||||
|
||||
// Serve frontend build files (if exists, for production)
|
||||
const path = require('path');
|
||||
const frontendDistPath = path.join(__dirname, '../../frontend/dist');
|
||||
const fs = require('fs');
|
||||
if (fs.existsSync(frontendDistPath)) {
|
||||
app.use(express.static(frontendDistPath));
|
||||
|
||||
// SPA fallback: serve index.html for all non-API routes
|
||||
app.get('*', (req, res, next) => {
|
||||
// Skip API routes and tracking routes
|
||||
if (req.path.startsWith('/api') || req.path.startsWith('/t/') || req.path.startsWith('/health')) {
|
||||
return next();
|
||||
}
|
||||
res.sendFile(path.join(frontendDistPath, 'index.html'));
|
||||
});
|
||||
}
|
||||
|
||||
// Session middleware
|
||||
app.use(session(sessionConfig));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user