From 1d744df55eeac400a3e700cd21b5ca90201512d3 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Sat, 14 Mar 2026 01:31:03 +0000 Subject: [PATCH] feat: serve frontend from backend for production deploy --- src/server/app.ts | 11 +++++++++++ vite.config.ts | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/server/app.ts b/src/server/app.ts index eac1fa8..f6a0d59 100644 --- a/src/server/app.ts +++ b/src/server/app.ts @@ -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; diff --git a/vite.config.ts b/vite.config.ts index f45af2c..0e8476c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,6 +4,9 @@ import { VitePWA } from 'vite-plugin-pwa' // https://vite.dev/config/ export default defineConfig({ + build: { + outDir: 'dist/client', + }, plugins: [ react(), VitePWA({