diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-17 15:04:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-17 15:04:54 +0200 |
commit | 62945f067b90961d6947287014ef5b64781d7ca1 (patch) | |
tree | cb04cb3b9f3ce46f20a92a7875d8a32704f652b6 /server.ts | |
parent | 0f7fedc39857ebc0eb29182c1588a92b9adfb75a (diff) | |
download | PeerTube-62945f067b90961d6947287014ef5b64781d7ca1.tar.gz PeerTube-62945f067b90961d6947287014ef5b64781d7ca1.tar.zst PeerTube-62945f067b90961d6947287014ef5b64781d7ca1.zip |
Add cors for static paths too
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 21 |
1 files changed, 5 insertions, 16 deletions
@@ -114,22 +114,11 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch | |||
114 | 114 | ||
115 | // Enable CORS for develop | 115 | // Enable CORS for develop |
116 | if (isTestInstance()) { | 116 | if (isTestInstance()) { |
117 | app.use((req, res, next) => { | 117 | app.use(cors({ |
118 | // These routes have already cors | 118 | origin: '*', |
119 | if ( | 119 | exposedHeaders: 'Retry-After', |
120 | req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && | 120 | credentials: true |
121 | req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 && | 121 | })) |
122 | req.path.startsWith('/api/') === false | ||
123 | ) { | ||
124 | return (cors({ | ||
125 | origin: '*', | ||
126 | exposedHeaders: 'Retry-After', | ||
127 | credentials: true | ||
128 | }))(req, res, next) | ||
129 | } | ||
130 | |||
131 | return next() | ||
132 | }) | ||
133 | } | 122 | } |
134 | 123 | ||
135 | // For the logger | 124 | // For the logger |