added docker setup
This commit is contained in:
Vendored
+14
@@ -66,6 +66,20 @@ app.use('/api', contractHistory_routes_js_1.default);
|
||||
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_1.default.join(process.cwd(), 'public');
|
||||
// Serve static files
|
||||
app.use(express_1.default.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_1.default.join(publicPath, 'index.html'));
|
||||
});
|
||||
}
|
||||
// Error handling
|
||||
app.use((err, req, res, next) => {
|
||||
console.error(err.stack);
|
||||
|
||||
Reference in New Issue
Block a user