aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2021-12-02 09:14:54 +0100
committerGitHub <noreply@github.com>2021-12-02 09:14:54 +0100
commit5fc44b57f8da090baccd7e4ea7d03773190e4e87 (patch)
tree5ce47e6194b8bc69e39459adef116eb32a12e0e1
parentdecbd0b63bf14b55c265b0faee18521e4b0e1e76 (diff)
downloadPeerTube-5fc44b57f8da090baccd7e4ea7d03773190e4e87.tar.gz
PeerTube-5fc44b57f8da090baccd7e4ea7d03773190e4e87.tar.zst
PeerTube-5fc44b57f8da090baccd7e4ea7d03773190e4e87.zip
Add header Vary Accept-Language (#4588)
* nginx: add header Vary Accept-Language solves #3647 * Revert "nginx: add header Vary Accept-Language" This reverts commit 90dccf53247882ad30904e4c950b745c4e859e01. * add resp header Vary Accept-Language solves #3647 * don't add vary header to embed page
-rw-r--r--server/controllers/client.ts10
-rw-r--r--server/lib/client-html.ts8
2 files changed, 11 insertions, 7 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index 703166c01..2157ae533 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -138,31 +138,31 @@ async function generateEmbedHtmlPage (req: express.Request, res: express.Respons
138async function generateWatchHtmlPage (req: express.Request, res: express.Response) { 138async function generateWatchHtmlPage (req: express.Request, res: express.Response) {
139 const html = await ClientHtml.getWatchHTMLPage(req.params.id + '', req, res) 139 const html = await ClientHtml.getWatchHTMLPage(req.params.id + '', req, res)
140 140
141 return sendHTML(html, res) 141 return sendHTML(html, res, true)
142} 142}
143 143
144async function generateWatchPlaylistHtmlPage (req: express.Request, res: express.Response) { 144async function generateWatchPlaylistHtmlPage (req: express.Request, res: express.Response) {
145 const html = await ClientHtml.getWatchPlaylistHTMLPage(req.params.id + '', req, res) 145 const html = await ClientHtml.getWatchPlaylistHTMLPage(req.params.id + '', req, res)
146 146
147 return sendHTML(html, res) 147 return sendHTML(html, res, true)
148} 148}
149 149
150async function generateAccountHtmlPage (req: express.Request, res: express.Response) { 150async function generateAccountHtmlPage (req: express.Request, res: express.Response) {
151 const html = await ClientHtml.getAccountHTMLPage(req.params.nameWithHost, req, res) 151 const html = await ClientHtml.getAccountHTMLPage(req.params.nameWithHost, req, res)
152 152
153 return sendHTML(html, res) 153 return sendHTML(html, res, true)
154} 154}
155 155
156async function generateVideoChannelHtmlPage (req: express.Request, res: express.Response) { 156async function generateVideoChannelHtmlPage (req: express.Request, res: express.Response) {
157 const html = await ClientHtml.getVideoChannelHTMLPage(req.params.nameWithHost, req, res) 157 const html = await ClientHtml.getVideoChannelHTMLPage(req.params.nameWithHost, req, res)
158 158
159 return sendHTML(html, res) 159 return sendHTML(html, res, true)
160} 160}
161 161
162async function generateActorHtmlPage (req: express.Request, res: express.Response) { 162async function generateActorHtmlPage (req: express.Request, res: express.Response) {
163 const html = await ClientHtml.getActorHTMLPage(req.params.nameWithHost, req, res) 163 const html = await ClientHtml.getActorHTMLPage(req.params.nameWithHost, req, res)
164 164
165 return sendHTML(html, res) 165 return sendHTML(html, res, true)
166} 166}
167 167
168async function generateManifest (req: express.Request, res: express.Response) { 168async function generateManifest (req: express.Request, res: express.Response) {
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index b2948254b..360b4667f 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -555,9 +555,13 @@ class ClientHtml {
555 } 555 }
556} 556}
557 557
558function sendHTML (html: string, res: express.Response) { 558function sendHTML (html: string, res: express.Response, localizedHTML: boolean = false) {
559 res.set('Content-Type', 'text/html; charset=UTF-8') 559 res.set('Content-Type', 'text/html; charset=UTF-8')
560 560
561 if (localizedHTML) {
562 res.set('Vary', 'Accept-Language')
563 }
564
561 return res.send(html) 565 return res.send(html)
562} 566}
563 567
@@ -586,5 +590,5 @@ export {
586async function generateHTMLPage (req: express.Request, res: express.Response, paramLang?: string) { 590async function generateHTMLPage (req: express.Request, res: express.Response, paramLang?: string) {
587 const html = await ClientHtml.getDefaultHTMLPage(req, res, paramLang) 591 const html = await ClientHtml.getDefaultHTMLPage(req, res, paramLang)
588 592
589 return sendHTML(html, res) 593 return sendHTML(html, res, true)
590} 594}