1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Server: move static/client routes in controllers/

This commit is contained in:
Chocobozzz 2016-11-25 12:32:21 +01:00
parent 8e124f999b
commit 79530164b6
4 changed files with 68 additions and 28 deletions

View file

@ -13,8 +13,9 @@ const Video = mongoose.model('Video')
const router = express.Router()
const opengraphComment = '<!-- opengraph tags -->'
const embedPath = path.join(__dirname, '../../client/dist/standalone/videos/embed.html')
const indexPath = path.join(__dirname, '../../client/dist/index.html')
const distPath = path.join(__dirname, '../../client/dist')
const embedPath = path.join(distPath, 'standalone/videos/embed.html')
const indexPath = path.join(distPath, 'index.html')
// Special route that add OpenGraph tags
// Do not use a template engine for a so little thing
@ -24,6 +25,14 @@ router.use('/videos/embed', function (req, res, next) {
res.sendFile(embedPath)
})
// Static HTML/CSS/JS client files
router.use('/client', express.static(distPath, { maxAge: constants.STATIC_MAX_AGE }))
// 404 for static files not found
router.use('/client/*', function (req, res, next) {
res.sendStatus(404)
})
// ---------------------------------------------------------------------------
module.exports = router