diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-11-25 12:32:21 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-11-25 14:21:41 +0100 |
commit | 79530164b6c8f96a6ccf6d33b591d565f1575e67 (patch) | |
tree | f610a32ad5cb7151247af12dcc1534d4adb7de37 /server/controllers/client.js | |
parent | 8e124f999b8cf7d461ef7a923711d18edc69d84c (diff) | |
download | PeerTube-79530164b6c8f96a6ccf6d33b591d565f1575e67.tar.gz PeerTube-79530164b6c8f96a6ccf6d33b591d565f1575e67.tar.zst PeerTube-79530164b6c8f96a6ccf6d33b591d565f1575e67.zip |
Server: move static/client routes in controllers/
Diffstat (limited to 'server/controllers/client.js')
-rw-r--r-- | server/controllers/client.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/server/controllers/client.js b/server/controllers/client.js index 61e094980..572db6133 100644 --- a/server/controllers/client.js +++ b/server/controllers/client.js | |||
@@ -13,8 +13,9 @@ const Video = mongoose.model('Video') | |||
13 | const router = express.Router() | 13 | const router = express.Router() |
14 | 14 | ||
15 | const opengraphComment = '<!-- opengraph tags -->' | 15 | const opengraphComment = '<!-- opengraph tags -->' |
16 | const embedPath = path.join(__dirname, '../../client/dist/standalone/videos/embed.html') | 16 | const distPath = path.join(__dirname, '../../client/dist') |
17 | const indexPath = path.join(__dirname, '../../client/dist/index.html') | 17 | const embedPath = path.join(distPath, 'standalone/videos/embed.html') |
18 | const indexPath = path.join(distPath, 'index.html') | ||
18 | 19 | ||
19 | // Special route that add OpenGraph tags | 20 | // Special route that add OpenGraph tags |
20 | // Do not use a template engine for a so little thing | 21 | // Do not use a template engine for a so little thing |
@@ -24,6 +25,14 @@ router.use('/videos/embed', function (req, res, next) { | |||
24 | res.sendFile(embedPath) | 25 | res.sendFile(embedPath) |
25 | }) | 26 | }) |
26 | 27 | ||
28 | // Static HTML/CSS/JS client files | ||
29 | router.use('/client', express.static(distPath, { maxAge: constants.STATIC_MAX_AGE })) | ||
30 | |||
31 | // 404 for static files not found | ||
32 | router.use('/client/*', function (req, res, next) { | ||
33 | res.sendStatus(404) | ||
34 | }) | ||
35 | |||
27 | // --------------------------------------------------------------------------- | 36 | // --------------------------------------------------------------------------- |
28 | 37 | ||
29 | module.exports = router | 38 | module.exports = router |