Consolidate to single server with unified package.json
- Merge client and server dependencies into root package.json - Remove separate client/package.json and server/package.json - Update server/index.js to serve built client static files - Simplify Dockerfile to single build + production stage - Update dev scripts for unified development workflow - SPA routing serves index.html for non-API routes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,21 @@ app.use(express.urlencoded({ extended: true, limit: '50mb' }));
|
||||
app.use('/uploads', express.static(uploadsDir));
|
||||
app.use('/exports', express.static(exportsDir));
|
||||
|
||||
// Serve built client static files
|
||||
const clientDistDir = join(__dirname, 'dist');
|
||||
if (existsSync(clientDistDir)) {
|
||||
app.use(express.static(clientDistDir));
|
||||
|
||||
// Serve index.html for all non-API routes (SPA routing)
|
||||
app.get('*', (req, res, next) => {
|
||||
if (!req.path.startsWith('/api') && !req.path.startsWith('/uploads') && !req.path.startsWith('/exports')) {
|
||||
res.sendFile(join(clientDistDir, 'index.html'));
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Configure multer for image uploads
|
||||
const storage = multer.diskStorage({
|
||||
destination: (req, file, cb) => {
|
||||
|
||||
Reference in New Issue
Block a user