mirror of
https://github.com/hotheadhacker/seedbox-lite.git
synced 2025-09-02 00:51:36 +03:00
Add production build scripts and ecosystem configurations for seedbox frontend
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -61,3 +61,4 @@ coverage/
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
server-new/.env.production
|
||||
|
||||
15
client/build-production.sh
Normal file
15
client/build-production.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Production build script
|
||||
echo "🔨 Building frontend for production..."
|
||||
|
||||
# Set production environment
|
||||
export NODE_ENV=production
|
||||
export VITE_API_BASE_URL=https://seedbox-api.isalman.dev
|
||||
|
||||
# Build the project
|
||||
npm run build
|
||||
|
||||
echo "✅ Production build complete!"
|
||||
echo "📦 Built files are in the 'dist' directory"
|
||||
echo "🌐 API Base URL: ${VITE_API_BASE_URL}"
|
||||
21
client/ecosystem-express.config.js
Normal file
21
client/ecosystem-express.config.js
Normal file
@@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'seedbox-frontend',
|
||||
script: 'server.js',
|
||||
cwd: '/home/toor/seedbox-lite/client',
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_memory_restart: '1G',
|
||||
error_file: './logs/frontend-error.log',
|
||||
out_file: './logs/frontend-out.log',
|
||||
log_file: './logs/frontend-combined.log',
|
||||
time: true,
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
PORT: 5174
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
21
client/ecosystem-simple.config.js
Normal file
21
client/ecosystem-simple.config.js
Normal file
@@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'seedbox-frontend',
|
||||
script: 'npx',
|
||||
args: ['serve', '-s', 'dist', '-l', '5174'],
|
||||
cwd: '/home/toor/seedbox-lite/client',
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_memory_restart: '1G',
|
||||
error_file: './logs/frontend-error.log',
|
||||
out_file: './logs/frontend-out.log',
|
||||
log_file: './logs/frontend-combined.log',
|
||||
time: true,
|
||||
env: {
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
23
client/ecosystem.config.js
Normal file
23
client/ecosystem.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'seedbox-frontend',
|
||||
script: 'serve',
|
||||
args: ['-s', 'dist', '-l', '5174', '-C'],
|
||||
env: {
|
||||
PM2_SERVE_PATH: './dist',
|
||||
PM2_SERVE_PORT: 5174,
|
||||
PM2_SERVE_SPA: 'true',
|
||||
PM2_SERVE_HOMEPAGE: '/index.html'
|
||||
},
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_memory_restart: '1G',
|
||||
error_file: './logs/frontend-error.log',
|
||||
out_file: './logs/frontend-out.log',
|
||||
log_file: './logs/frontend-combined.log',
|
||||
time: true
|
||||
}
|
||||
]
|
||||
};
|
||||
18
client/server.js
Normal file
18
client/server.js
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 5174;
|
||||
|
||||
// Serve static files from dist directory
|
||||
app.use(express.static(path.join(__dirname, 'dist')));
|
||||
|
||||
// Handle React Router - send all requests to index.html
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 Frontend server running on http://localhost:${PORT}`);
|
||||
});
|
||||
@@ -19,7 +19,7 @@ const config = {
|
||||
omdb: {
|
||||
apiKey: process.env.OMDB_API_KEY || '8265bd1c' // Free API key for development
|
||||
},
|
||||
isDevelopment: process.env.NODE_ENV === 'development'
|
||||
isDevelopment: process.env.NODE_ENV !== 'production'
|
||||
};
|
||||
|
||||
const app = express();
|
||||
@@ -630,14 +630,28 @@ const upload = multer({
|
||||
});
|
||||
|
||||
// CORS Configuration
|
||||
const allowedOrigins = [
|
||||
config.frontend.url,
|
||||
'http://localhost:5173',
|
||||
'http://localhost:5174',
|
||||
'http://localhost:3000',
|
||||
'http://127.0.0.1:5173',
|
||||
'http://127.0.0.1:5174',
|
||||
'http://127.0.0.1:3000'
|
||||
];
|
||||
|
||||
// Add production domains if not in development
|
||||
if (!config.isDevelopment) {
|
||||
allowedOrigins.push(
|
||||
'https://seedbox.isalman.dev',
|
||||
'https://seedbox-api.isalman.dev'
|
||||
);
|
||||
}
|
||||
|
||||
console.log('🌐 CORS allowed origins:', allowedOrigins);
|
||||
|
||||
app.use(cors({
|
||||
origin: [
|
||||
config.frontend.url,
|
||||
'http://localhost:5173',
|
||||
'http://localhost:3000',
|
||||
'http://127.0.0.1:5173',
|
||||
'http://127.0.0.1:3000'
|
||||
],
|
||||
origin: allowedOrigins,
|
||||
credentials: true,
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
||||
allowedHeaders: ['Content-Type', 'Authorization']
|
||||
|
||||
Reference in New Issue
Block a user