split containers

This commit is contained in:
2026-01-29 00:40:29 -05:00
parent b2886cbcb0
commit f689689281
4 changed files with 61 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ import express from 'express';
import cors from 'cors';
import dotenv from 'dotenv';
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
import { initDB } from './db/index.js';
import authRoutes from './routes/auth.js';
@@ -37,12 +38,24 @@ app.get('/api/health', (req, res) => {
// Serve static frontend files (for production)
const frontendPath = path.join(__dirname, '../../frontend/dist');
app.use(express.static(frontendPath));
const frontendExists = fs.existsSync(frontendPath);
// Serve index.html for all non-API routes (SPA support)
app.get('*', (req, res) => {
res.sendFile(path.join(frontendPath, 'index.html'));
});
if (frontendExists) {
app.use(express.static(frontendPath));
// Serve index.html for all non-API routes (SPA support)
app.get('*', (req, res) => {
res.sendFile(path.join(frontendPath, 'index.html'));
});
} else {
console.log(' Frontend dist not found - running in API-only mode (dev)');
app.get('*', (req, res) => {
res.json({
message: "What's The Point API - Frontend running separately",
frontend: "http://localhost:5173"
});
});
}
const PORT = process.env.PORT || 4000;