open CORS to allow in-browser apps to communicate w/ PeerTube instances
This commit is contained in:
parent
fc0941cbec
commit
1fd2d96ff8
1 changed files with 15 additions and 17 deletions
32
server.ts
32
server.ts
|
@ -84,24 +84,22 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch
|
||||||
|
|
||||||
// ----------- App -----------
|
// ----------- App -----------
|
||||||
|
|
||||||
// Enable CORS for develop
|
// Enable CORS
|
||||||
if (isTestInstance()) {
|
app.use((req, res, next) => {
|
||||||
app.use((req, res, next) => {
|
// These routes have already cors
|
||||||
// These routes have already cors
|
if (
|
||||||
if (
|
req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 &&
|
||||||
req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 &&
|
req.path.indexOf(STATIC_PATHS.WEBSEED) === -1
|
||||||
req.path.indexOf(STATIC_PATHS.WEBSEED) === -1
|
) {
|
||||||
) {
|
return (cors({
|
||||||
return (cors({
|
origin: '*',
|
||||||
origin: '*',
|
exposedHeaders: 'Retry-After',
|
||||||
exposedHeaders: 'Retry-After',
|
credentials: true
|
||||||
credentials: true
|
}))(req, res, next)
|
||||||
}))(req, res, next)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return next()
|
return next()
|
||||||
})
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// For the logger
|
// For the logger
|
||||||
app.use(morgan('combined', {
|
app.use(morgan('combined', {
|
||||||
|
|
Loading…
Add table
Reference in a new issue