added docker setup
This commit is contained in:
@@ -69,6 +69,23 @@ app.get('/api/health', (req, res) => {
|
||||
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
||||
});
|
||||
|
||||
// Production: Serve frontend static files
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
const publicPath = path.join(process.cwd(), 'public');
|
||||
|
||||
// Serve static files
|
||||
app.use(express.static(publicPath));
|
||||
|
||||
// SPA fallback: serve index.html for all non-API routes
|
||||
app.get('*', (req, res, next) => {
|
||||
// Skip API routes
|
||||
if (req.path.startsWith('/api')) {
|
||||
return next();
|
||||
}
|
||||
res.sendFile(path.join(publicPath, 'index.html'));
|
||||
});
|
||||
}
|
||||
|
||||
// Error handling
|
||||
app.use((err: Error, req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
console.error(err.stack);
|
||||
|
||||
Reference in New Issue
Block a user