diff options
author | Chocobozzz <me@florianbigard.com> | 2020-02-27 09:09:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-27 09:09:50 +0100 |
commit | 16ec5e0833a4f72e75ca2a4f4be00f0453c68c80 (patch) | |
tree | 5b33355cebd25e57cf4695ac59ada14c087c083c /server/controllers/client.ts | |
parent | e81871782db9927b2eb14b5deeb03b4e7b3cce0a (diff) | |
parent | 195ba6cdf38f4515a514cf8432930576539b0a04 (diff) | |
download | PeerTube-16ec5e0833a4f72e75ca2a4f4be00f0453c68c80.tar.gz PeerTube-16ec5e0833a4f72e75ca2a4f4be00f0453c68c80.tar.zst PeerTube-16ec5e0833a4f72e75ca2a4f4be00f0453c68c80.zip |
Merge branch 'release/2.1.0'
Diffstat (limited to 'server/controllers/client.ts')
-rw-r--r-- | server/controllers/client.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index dc3ff18fc..56685f102 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -2,10 +2,11 @@ import * as express from 'express' | |||
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { root } from '../helpers/core-utils' | 3 | import { root } from '../helpers/core-utils' |
4 | import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' | 4 | import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' |
5 | import { asyncMiddleware } from '../middlewares' | 5 | import { asyncMiddleware, embedCSP } from '../middlewares' |
6 | import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n' | 6 | import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n' |
7 | import { ClientHtml } from '../lib/client-html' | 7 | import { ClientHtml } from '../lib/client-html' |
8 | import { logger } from '../helpers/logger' | 8 | import { logger } from '../helpers/logger' |
9 | import { CONFIG } from '@server/initializers/config' | ||
9 | 10 | ||
10 | const clientsRouter = express.Router() | 11 | const clientsRouter = express.Router() |
11 | 12 | ||
@@ -19,8 +20,13 @@ clientsRouter.use('/videos/watch/:id', asyncMiddleware(generateWatchHtmlPage)) | |||
19 | clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage)) | 20 | clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage)) |
20 | clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage)) | 21 | clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage)) |
21 | 22 | ||
23 | const embedCSPMiddleware = CONFIG.CSP.ENABLED | ||
24 | ? embedCSP | ||
25 | : (req: express.Request, res: express.Response, next: express.NextFunction) => next() | ||
26 | |||
22 | clientsRouter.use( | 27 | clientsRouter.use( |
23 | '/videos/embed', | 28 | '/videos/embed', |
29 | embedCSPMiddleware, | ||
24 | (req: express.Request, res: express.Response) => { | 30 | (req: express.Request, res: express.Response) => { |
25 | res.removeHeader('X-Frame-Options') | 31 | res.removeHeader('X-Frame-Options') |
26 | res.sendFile(embedPath) | 32 | res.sendFile(embedPath) |