open CORS to allow in-browser apps to communicate w/ PeerTube instances

pull/753/head
William Lahti 2018-06-27 19:22:51 -07:00 committed by Chocobozzz
parent fc0941cbec
commit 1fd2d96ff8
1 changed files with 15 additions and 17 deletions

View File

@ -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', {