Add cors for static paths too

pull/821/head
Chocobozzz 2018-07-17 15:04:54 +02:00
parent 0f7fedc398
commit 62945f067b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 7 additions and 16 deletions

View File

@ -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

View File

@ -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
*/