From: Chocobozzz Date: Tue, 17 Jul 2018 13:04:54 +0000 (+0200) Subject: Add cors for static paths too X-Git-Tag: v1.0.0-beta.10.pre.1~47 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=62945f067b90961d6947287014ef5b64781d7ca1;p=github%2FChocobozzz%2FPeerTube.git Add cors for static paths too --- diff --git a/server.ts b/server.ts index a688bb5d0..7dffb6576 100644 --- a/server.ts +++ b/server.ts @@ -114,22 +114,11 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch // Enable CORS for develop if (isTestInstance()) { - app.use((req, res, next) => { - // These routes have already cors - if ( - req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && - req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 && - req.path.startsWith('/api/') === false - ) { - return (cors({ - origin: '*', - exposedHeaders: 'Retry-After', - credentials: true - }))(req, res, next) - } - - return next() - }) + app.use(cors({ + origin: '*', + exposedHeaders: 'Retry-After', + credentials: true + })) } // For the logger diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 679999859..1600068e0 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -8,6 +8,8 @@ import { VideosCaptionCache } from '../lib/cache/videos-caption-cache' const staticRouter = express.Router() +staticRouter.use(cors()) + /* Cors is very important to let other servers access torrent and video files */