diff options
Diffstat (limited to 'server.js')
| -rw-r--r-- | server.js | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -265,6 +265,14 @@ api.post('/rooms/:id/check', (req, res) => { app.use('/api', api); const publicDir = path.join(__dirname, 'public'); + +// The page with the site's name already in it, so it never shows the default first. +const escapeHtml = (text) => text.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`); +const indexHtml = require('fs').readFileSync(path.join(publicDir, 'index.html'), 'utf8') + .replace('<title>Yesod</title>', `<title>${escapeHtml(SITE_NAME)}</title>`) + .replace('<b id="site-name">Yesod</b>', `<b id="site-name">${escapeHtml(SITE_NAME)}</b>`); +app.get(['/', '/index.html'], (req, res) => res.set('Cache-Control', 'no-cache').type('html').send(indexHtml)); + app.use('/assets', express.static(path.join(publicDir, 'assets'), { maxAge: '7d' })); app.use('/vendor', express.static(path.join(publicDir, 'vendor'), { maxAge: '30d', immutable: true })); app.use(express.static(publicDir, { maxAge: 0 })); |