Benny-Tang's picture
Create server-fix.js
3759562 verified
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}/` );
});