diff --git a/package.json b/package.json index 3924e74..7e31cbf 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "dotenv": "^16.3.1", "express": "^4.18.2", "express-session": "^1.17.3", + "ejs": "^3.1.10", "libsodium-wrappers": "^0.7.13", "play-dl": "^1.9.7", "sodium-native": "^4.0.4", diff --git a/src/web/server.ts b/src/web/server.ts index eeba68d..c34babf 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -12,6 +12,11 @@ export function createWebServer() { const basePath = env.webBasePath || '/ucp'; const dashboardPath = `${basePath}/dashboard`; 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(cookieParser()); app.use( @@ -23,6 +28,7 @@ export function createWebServer() { ); const mount = (suffix: string) => (basePath ? `${basePath}${suffix}` : suffix); + app.use(mount('/public'), express.static(publicPath)); app.use(mount('/auth'), authRouter); app.use(dashboardPath, dashboardRouter); app.use(mount('/api'), apiRouter); @@ -30,6 +36,7 @@ export function createWebServer() { if (basePath) { app.use('/api', apiRouter); app.use('/dashboard', dashboardRouter); + app.use('/public', express.static(publicPath)); } // Redirect bare auth calls to the prefixed path when a base path is set