diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-07 15:12:53 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-07 15:12:53 +0200 |
commit | b9ab2e25fd7fff1ded999153371fb4699c9abaf1 (patch) | |
tree | fc5227ef376f9bfb8614f381d9ce6619a0bbbb97 /server.js | |
parent | d22629bd9356193aa6b956dec84cd3b7eb08d12a (diff) | |
download | PeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.tar.gz PeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.tar.zst PeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.zip |
Server: add cors policy for torrent file and thumbnails
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | // ----------- Node modules ----------- | 3 | // ----------- Node modules ----------- |
4 | const bodyParser = require('body-parser') | 4 | const bodyParser = require('body-parser') |
5 | const cors = require('cors') | ||
5 | const express = require('express') | 6 | const express = require('express') |
6 | const expressValidator = require('express-validator') | 7 | const expressValidator = require('express-validator') |
7 | const http = require('http') | 8 | const http = require('http') |
@@ -74,11 +75,11 @@ app.use('/client/*', function (req, res, next) { | |||
74 | }) | 75 | }) |
75 | 76 | ||
76 | const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents')) | 77 | const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents')) |
77 | app.use(constants.STATIC_PATHS.TORRENTS, express.static(torrentsPhysicalPath, { maxAge: 0 })) | 78 | app.use(constants.STATIC_PATHS.TORRENTS, cors(), express.static(torrentsPhysicalPath, { maxAge: 0 })) |
78 | 79 | ||
79 | // Uploads path for webseeding | 80 | // Uploads path for webseeding |
80 | const uploadsPhysicalPath = path.join(__dirname, config.get('storage.uploads')) | 81 | const uploadsPhysicalPath = path.join(__dirname, config.get('storage.uploads')) |
81 | app.use(constants.STATIC_PATHS.WEBSEED, express.static(uploadsPhysicalPath, { maxAge: 0 })) | 82 | app.use(constants.STATIC_PATHS.WEBSEED, cors(), express.static(uploadsPhysicalPath, { maxAge: 0 })) |
82 | 83 | ||
83 | // Thumbnails path for express | 84 | // Thumbnails path for express |
84 | const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails')) | 85 | const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails')) |