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