diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-24 11:25:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-08-24 11:25:40 +0200 |
commit | cf649c2ed918b3cc6bd4c92f38c7752174ac1e9a (patch) | |
tree | 11f3be3a12ee6f717d1e814e26fa802a8ac871bc /server/controllers/client.ts | |
parent | 5505981154195131f961beeba355cc1d173983f7 (diff) | |
download | PeerTube-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.ts | 18 |
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' | |||
12 | const clientsRouter = express.Router() | 12 | const clientsRouter = express.Router() |
13 | 13 | ||
14 | const distPath = join(root(), 'client', 'dist') | 14 | const distPath = join(root(), 'client', 'dist') |
15 | const embedPath = join(distPath, 'standalone', 'videos', 'embed.html') | ||
16 | const testEmbedPath = join(distPath, 'standalone', 'videos', 'test-embed.html') | 15 | const 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 | ||
37 | clientsRouter.use('/videos/embed', ...embedMiddlewares) | 41 | clientsRouter.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 | ||
132 | async function generateEmbedHtmlPage (req: express.Request, res: express.Response) { | ||
133 | const html = await ClientHtml.getEmbedHTML() | ||
134 | |||
135 | return sendHTML(html, res) | ||
136 | } | ||
137 | |||
128 | async function generateHTMLPage (req: express.Request, res: express.Response, paramLang?: string) { | 138 | async 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 | ||