aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/client.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-24 11:25:40 +0200
committerChocobozzz <me@florianbigard.com>2020-08-24 11:25:40 +0200
commitcf649c2ed918b3cc6bd4c92f38c7752174ac1e9a (patch)
tree11f3be3a12ee6f717d1e814e26fa802a8ac871bc /server/controllers/client.ts
parent5505981154195131f961beeba355cc1d173983f7 (diff)
downloadPeerTube-cf649c2ed918b3cc6bd4c92f38c7752174ac1e9a.tar.gz
PeerTube-cf649c2ed918b3cc6bd4c92f38c7752174ac1e9a.tar.zst
PeerTube-cf649c2ed918b3cc6bd4c92f38c7752174ac1e9a.zip
Inject plugin CSS in embed too
Diffstat (limited to 'server/controllers/client.ts')
-rw-r--r--server/controllers/client.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index 39a198b59..335a0e082 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -12,7 +12,6 @@ import { asyncMiddleware, embedCSP } from '../middlewares'
12const clientsRouter = express.Router() 12const clientsRouter = express.Router()
13 13
14const distPath = join(root(), 'client', 'dist') 14const distPath = join(root(), 'client', 'dist')
15const embedPath = join(distPath, 'standalone', 'videos', 'embed.html')
16const testEmbedPath = join(distPath, 'standalone', 'videos', 'test-embed.html') 15const testEmbedPath = join(distPath, 'standalone', 'videos', 'test-embed.html')
17 16
18// Special route that add OpenGraph and oEmbed tags 17// Special route that add OpenGraph and oEmbed tags
@@ -27,11 +26,16 @@ const embedMiddlewares = [
27 ? embedCSP 26 ? embedCSP
28 : (req: express.Request, res: express.Response, next: express.NextFunction) => next(), 27 : (req: express.Request, res: express.Response, next: express.NextFunction) => next(),
29 28
30 (req: express.Request, res: express.Response) => { 29 (req: express.Request, res: express.Response, next: express.NextFunction) => {
31 res.removeHeader('X-Frame-Options') 30 res.removeHeader('X-Frame-Options')
31
32 // Don't cache HTML file since it's an index to the immutable JS/CSS files 32 // Don't cache HTML file since it's an index to the immutable JS/CSS files
33 res.sendFile(embedPath, { maxAge: 0 }) 33 res.setHeader('Cache-Control', 'public, max-age=0')
34 } 34
35 next()
36 },
37
38 asyncMiddleware(generateEmbedHtmlPage)
35] 39]
36 40
37clientsRouter.use('/videos/embed', ...embedMiddlewares) 41clientsRouter.use('/videos/embed', ...embedMiddlewares)
@@ -125,6 +129,12 @@ async function serveIndexHTML (req: express.Request, res: express.Response) {
125 return res.status(404).end() 129 return res.status(404).end()
126} 130}
127 131
132async function generateEmbedHtmlPage (req: express.Request, res: express.Response) {
133 const html = await ClientHtml.getEmbedHTML()
134
135 return sendHTML(html, res)
136}
137
128async function generateHTMLPage (req: express.Request, res: express.Response, paramLang?: string) { 138async function generateHTMLPage (req: express.Request, res: express.Response, paramLang?: string) {
129 const html = await ClientHtml.getDefaultHTMLPage(req, res, paramLang) 139 const html = await ClientHtml.getDefaultHTMLPage(req, res, paramLang)
130 140