feat: serve frontend from backend for production deploy
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -4,6 +4,9 @@ import { VitePWA } from 'vite-plugin-pwa'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: 'dist/client',
|
||||
},
|
||||
plugins: [
|
||||
react(),
|
||||
VitePWA({
|
||||
|
||||
Reference in New Issue
Block a user