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) => {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "apparel-designer-server",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "DYLD_INSERT_LIBRARIES='' node --watch index.js",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"cors": "^2.8.5",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"sharp": "^0.33.2",
|
||||
"uuid": "^9.0.1",
|
||||
"canvas": "^2.11.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user