Harden MVP runtime and fix packaged desktop white screen

This commit is contained in:
Ryan Lancaster
2026-03-18 13:05:14 -04:00
parent 9302a88aea
commit 4a7b3061ed
14 changed files with 359 additions and 29 deletions

View File

@@ -214,13 +214,16 @@ const app = express();
app.use(helmet());
app.use(morgan(process.env.MORGAN_FORMAT || 'combined'));
const defaultBackendPort = String(process.env.PORT || process.env.PORT_BACKEND || '4000');
const defaultFrontendPort = String(process.env.PORT_FRONTEND_DEV || '5173');
const configuredOrigins = (process.env.CORS_ORIGIN || '')
.split(',')
.map(o => o.trim())
.filter(Boolean);
const allowedOrigins = configuredOrigins.length
? configuredOrigins
: ['http://localhost:5173', 'http://localhost:4000', 'null'];
: [`http://localhost:${defaultFrontendPort}`, `http://localhost:${defaultBackendPort}`, 'null'];
const corsOptions = {
credentials: true,
@@ -544,7 +547,7 @@ app.post('/api/projects/:id/invites', limiter, requireApiKey, async (req, res) =
// Fire email if SMTP configured and email provided
if (req.body.email) {
const appUrl = process.env.APP_URL || 'http://localhost:5173';
const appUrl = process.env.APP_URL || `http://localhost:${defaultFrontendPort}`;
notify({
notifyEmail: req.body.email,
subject: `You've been invited to "${project.name}"`,
@@ -602,6 +605,6 @@ app.post('/api/invites/:token/accept', limiter, async (req, res) => {
res.json({ projectId: invite.projectId, projectName: invite.projectName });
});
const PORT = process.env.PORT || 4000;
const PORT = process.env.PORT || process.env.PORT_BACKEND || 4000;
const HOST = process.env.HOST || '0.0.0.0';
app.listen(PORT, HOST, () => console.log(`Backend running on ${HOST}:${PORT}`));