From 1fd2d96ff81ffd433d10a489dd1796688c695014 Mon Sep 17 00:00:00 2001 From: William Lahti Date: Wed, 27 Jun 2018 19:22:51 -0700 Subject: [PATCH] open CORS to allow in-browser apps to communicate w/ PeerTube instances --- server.ts | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/server.ts b/server.ts index 5511c5435..adebd9ce9 100644 --- a/server.ts +++ b/server.ts @@ -84,24 +84,22 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch // ----------- App ----------- -// 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 - ) { - return (cors({ - origin: '*', - exposedHeaders: 'Retry-After', - credentials: true - }))(req, res, next) - } +// Enable CORS +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 + ) { + return (cors({ + origin: '*', + exposedHeaders: 'Retry-After', + credentials: true + }))(req, res, next) + } - return next() - }) -} + return next() +}); // For the logger app.use(morgan('combined', {