Spaces:
Runtime error
Runtime error
File size: 673 Bytes
3759562 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
const PORT = process.env.PORT || 7860;
// Serve static files from client/dist
app.use(express.static(path.join(__dirname, 'client/dist')));
// Serve API routes
app.get('/api/health', (req, res) => {
res.json({ status: 'ok' });
});
// Fallback to index.html for SPA
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'client/dist/index.html'));
});
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}/` );
});
|