aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-07 15:12:53 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-07 15:12:53 +0200
commitb9ab2e25fd7fff1ded999153371fb4699c9abaf1 (patch)
treefc5227ef376f9bfb8614f381d9ce6619a0bbbb97
parentd22629bd9356193aa6b956dec84cd3b7eb08d12a (diff)
downloadPeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.tar.gz
PeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.tar.zst
PeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.zip
Server: add cors policy for torrent file and thumbnails
-rw-r--r--package.json1
-rw-r--r--server.js5
2 files changed, 4 insertions, 2 deletions
diff --git a/package.json b/package.json
index 909c18176..a7f76da52 100644
--- a/package.json
+++ b/package.json
@@ -40,6 +40,7 @@
40 "body-parser": "^1.12.4", 40 "body-parser": "^1.12.4",
41 "concurrently": "^2.0.0", 41 "concurrently": "^2.0.0",
42 "config": "^1.14.0", 42 "config": "^1.14.0",
43 "cors": "^2.8.1",
43 "create-torrent": "^3.24.5", 44 "create-torrent": "^3.24.5",
44 "debug": "^2.2.0", 45 "debug": "^2.2.0",
45 "dezalgo": "^1.0.3", 46 "dezalgo": "^1.0.3",
diff --git a/server.js b/server.js
index 5feb21476..e90ed5c25 100644
--- a/server.js
+++ b/server.js
@@ -2,6 +2,7 @@
2 2
3// ----------- Node modules ----------- 3// ----------- Node modules -----------
4const bodyParser = require('body-parser') 4const bodyParser = require('body-parser')
5const cors = require('cors')
5const express = require('express') 6const express = require('express')
6const expressValidator = require('express-validator') 7const expressValidator = require('express-validator')
7const http = require('http') 8const http = require('http')
@@ -74,11 +75,11 @@ app.use('/client/*', function (req, res, next) {
74}) 75})
75 76
76const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents')) 77const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents'))
77app.use(constants.STATIC_PATHS.TORRENTS, express.static(torrentsPhysicalPath, { maxAge: 0 })) 78app.use(constants.STATIC_PATHS.TORRENTS, cors(), express.static(torrentsPhysicalPath, { maxAge: 0 }))
78 79
79// Uploads path for webseeding 80// Uploads path for webseeding
80const uploadsPhysicalPath = path.join(__dirname, config.get('storage.uploads')) 81const uploadsPhysicalPath = path.join(__dirname, config.get('storage.uploads'))
81app.use(constants.STATIC_PATHS.WEBSEED, express.static(uploadsPhysicalPath, { maxAge: 0 })) 82app.use(constants.STATIC_PATHS.WEBSEED, cors(), express.static(uploadsPhysicalPath, { maxAge: 0 }))
82 83
83// Thumbnails path for express 84// Thumbnails path for express
84const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails')) 85const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails'))