mirror of https://github.com/Chocobozzz/PeerTube
Add cors for static paths too
parent
0f7fedc398
commit
62945f067b
21
server.ts
21
server.ts
|
@ -114,22 +114,11 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch
|
||||||
|
|
||||||
// Enable CORS for develop
|
// Enable CORS for develop
|
||||||
if (isTestInstance()) {
|
if (isTestInstance()) {
|
||||||
app.use((req, res, next) => {
|
app.use(cors({
|
||||||
// These routes have already cors
|
origin: '*',
|
||||||
if (
|
exposedHeaders: 'Retry-After',
|
||||||
req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 &&
|
credentials: true
|
||||||
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()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the logger
|
// For the logger
|
||||||
|
|
|
@ -8,6 +8,8 @@ import { VideosCaptionCache } from '../lib/cache/videos-caption-cache'
|
||||||
|
|
||||||
const staticRouter = express.Router()
|
const staticRouter = express.Router()
|
||||||
|
|
||||||
|
staticRouter.use(cors())
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Cors is very important to let other servers access torrent and video files
|
Cors is very important to let other servers access torrent and video files
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue