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 | |
parent | d22629bd9356193aa6b956dec84cd3b7eb08d12a (diff) | |
download | PeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.tar.gz PeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.tar.zst PeerTube-b9ab2e25fd7fff1ded999153371fb4699c9abaf1.zip |
Server: add cors policy for torrent file and thumbnails
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | server.js | 5 |
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", |
@@ -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')) |