feat: serve frontend from backend for production deploy

This commit is contained in:
2026-03-14 01:31:03 +00:00
parent b4ffe72b3e
commit 1d744df55e
2 changed files with 14 additions and 0 deletions

View File

@@ -71,4 +71,15 @@ app.get('/health', (req, res) => {
res.json({ status: 'ok', timestamp: new Date() });
});
// Serve frontend static files
const clientPath = path.join(process.cwd(), 'dist', 'client');
if (fs.existsSync(clientPath)) {
app.use(express.static(clientPath));
app.get('*', (req, res) => {
if (!req.path.startsWith('/api') && !req.path.startsWith('/uploads')) {
res.sendFile(path.join(clientPath, 'index.html'));
}
});
}
export default app;

View File

@@ -4,6 +4,9 @@ import { VitePWA } from 'vite-plugin-pwa'
// https://vite.dev/config/
export default defineConfig({
build: {
outDir: 'dist/client',
},
plugins: [
react(),
VitePWA({