diff options
author | William Lahti <wilahti@gmail.com> | 2018-06-28 20:23:26 -0700 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-29 09:46:44 +0200 |
commit | 12daa83784ea112e33d3b8b590a805dae9a29c1c (patch) | |
tree | 1b2939ea315f9447edff140f221b396d3334cb20 /server.ts | |
parent | b229e38d50c43221b8fa21cf7c778212f2742e93 (diff) | |
download | PeerTube-12daa83784ea112e33d3b8b590a805dae9a29c1c.tar.gz PeerTube-12daa83784ea112e33d3b8b590a805dae9a29c1c.tar.zst PeerTube-12daa83784ea112e33d3b8b590a805dae9a29c1c.zip |
move CORS allowance to the REST API router
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 34 |
1 files changed, 18 insertions, 16 deletions
@@ -84,22 +84,24 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch | |||
84 | 84 | ||
85 | // ----------- App ----------- | 85 | // ----------- App ----------- |
86 | 86 | ||
87 | // Enable CORS | 87 | // Enable CORS for develop |
88 | app.use((req, res, next) => { | 88 | if (isTestInstance()) { |
89 | // These routes have already cors | 89 | app.use((req, res, next) => { |
90 | if ( | 90 | // These routes have already cors |
91 | req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && | 91 | if ( |
92 | req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 | 92 | req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && |
93 | ) { | 93 | req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 |
94 | return (cors({ | 94 | ) { |
95 | origin: '*', | 95 | return (cors({ |
96 | exposedHeaders: 'Retry-After', | 96 | origin: '*', |
97 | credentials: true | 97 | exposedHeaders: 'Retry-After', |
98 | }))(req, res, next) | 98 | credentials: true |
99 | } | 99 | }))(req, res, next) |
100 | 100 | } | |
101 | return next() | 101 | |
102 | }) | 102 | return next() |
103 | }) | ||
104 | } | ||
103 | 105 | ||
104 | // For the logger | 106 | // For the logger |
105 | app.use(morgan('combined', { | 107 | app.use(morgan('combined', { |