[deploy] Configure view engine and static public
Some checks failed
Deploy Discord Bot / deploy (push) Failing after 20s

This commit is contained in:
Pascal Prießnitz
2025-12-04 16:46:20 +01:00
parent 22caa79b54
commit 5ba20024cc
2 changed files with 8 additions and 0 deletions

View File

@@ -23,6 +23,7 @@
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
"express-session": "^1.17.3", "express-session": "^1.17.3",
"ejs": "^3.1.10",
"libsodium-wrappers": "^0.7.13", "libsodium-wrappers": "^0.7.13",
"play-dl": "^1.9.7", "play-dl": "^1.9.7",
"sodium-native": "^4.0.4", "sodium-native": "^4.0.4",

View File

@@ -12,6 +12,11 @@ export function createWebServer() {
const basePath = env.webBasePath || '/ucp'; const basePath = env.webBasePath || '/ucp';
const dashboardPath = `${basePath}/dashboard`; const dashboardPath = `${basePath}/dashboard`;
const apiPath = `${basePath}/api`; const apiPath = `${basePath}/api`;
const viewsPath = path.join(process.cwd(), 'views');
const publicPath = path.join(process.cwd(), 'public');
app.set('views', viewsPath);
app.set('view engine', 'ejs');
app.use(express.json({ limit: '5mb' })); app.use(express.json({ limit: '5mb' }));
app.use(cookieParser()); app.use(cookieParser());
app.use( app.use(
@@ -23,6 +28,7 @@ export function createWebServer() {
); );
const mount = (suffix: string) => (basePath ? `${basePath}${suffix}` : suffix); const mount = (suffix: string) => (basePath ? `${basePath}${suffix}` : suffix);
app.use(mount('/public'), express.static(publicPath));
app.use(mount('/auth'), authRouter); app.use(mount('/auth'), authRouter);
app.use(dashboardPath, dashboardRouter); app.use(dashboardPath, dashboardRouter);
app.use(mount('/api'), apiRouter); app.use(mount('/api'), apiRouter);
@@ -30,6 +36,7 @@ export function createWebServer() {
if (basePath) { if (basePath) {
app.use('/api', apiRouter); app.use('/api', apiRouter);
app.use('/dashboard', dashboardRouter); app.use('/dashboard', dashboardRouter);
app.use('/public', express.static(publicPath));
} }
// Redirect bare auth calls to the prefixed path when a base path is set // Redirect bare auth calls to the prefixed path when a base path is set