-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (28 loc) · 975 Bytes
/
Copy pathapp.js
File metadata and controls
32 lines (28 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import multisite from '@apostrophecms-pro/multisite';
import sites from './sites/index.js';
import dashboard from './dashboard/index.js';
import domains from './domains.js';
const env = process.env.ENV || 'local';
const protocol = (process.env.NODE_ENV === 'production') ? 'https' : 'http';
const dashboardShortName = process.env.APOS_DASHBOARD_SHORTNAME || 'dashboard';
try {
await multisite({
root: import.meta,
shortNamePrefix: 'public-demo-',
// Default port, for dev
port: 3000,
mongodbUrl: 'mongodb://localhost:27017',
dashboardShortName,
sessionSecret: 'M1C0p#q(@(*#Y(WE&H',
sites,
dashboard,
orphan: function (req, res) {
const domain = domains[env] || domains.local;
return res.redirect(`${protocol}://${dashboardShortName}.${domain}`);
}
});
} catch (e) {
// eslint-disable-next-line no-console
console.error('An error occurred while starting the multisite application:', e);
process.exit(1);
}