birthday / server.js
teganmosi
Add Docker deployment config and application source code
3119726
Raw
History Blame Contribute Delete
606 Bytes
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 the 'dist' directory
app.use(express.static(path.join(__dirname, 'dist')));
// Fallback all requests to index.html for SPA routing support
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
});
app.listen(PORT, '0.0.0.0', () => {
console.log(`Server is running on port ${PORT}`);
});