move CORS allowance to the REST API router
This commit is contained in:
parent
b229e38d50
commit
12daa83784
2 changed files with 24 additions and 15 deletions
32
server.ts
32
server.ts
|
@ -84,22 +84,24 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch
|
|||
|
||||
// ----------- App -----------
|
||||
|
||||
// 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)
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
|
||||
return next()
|
||||
})
|
||||
return next()
|
||||
})
|
||||
}
|
||||
|
||||
// For the logger
|
||||
app.use(morgan('combined', {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue