import express from 'express'; import path from 'path'; const app = express(); const port = process.env.PORT || 3000; const distDir = path.resolve('dist'); app.use(express.static(distDir)); // For any route not matched by static files, serve index.html app.get('*', (req, res) => { res.sendFile(path.join(distDir, 'index.html')); }); app.listen(port, () => { console.log(`Server running at http://localhost:${port}`); }); // // server.js (if Vite base is '/') // import http from 'http'; // import path from 'path'; // import handler from 'serve-handler'; // const port = process.env.PORT || 3000; // const server = http.createServer((request, response) => { // return handler(request, response, { // public: 'dist', // cleanUrls: true, // <--- This was the missing line from your current server.js // rewrites: [ // // For any path that doesn't match a static file, serve index.html // { source: '/**', destination: '/index.html' } // ] // }); // }); // server.listen(port, () => { // console.log(`Frontend server running at http://localhost:${port}`); // });