Prevent invalid config injected in HTML
This commit is contained in:
parent
2898445c53
commit
b9200c6411
14
server.ts
14
server.ts
|
@ -86,7 +86,8 @@ app.use('/*', async function (req, res) {
|
||||||
: ''
|
: ''
|
||||||
|
|
||||||
// Stringify the JSON object, and then stringify the string object so we can inject it into the HTML
|
// Stringify the JSON object, and then stringify the string object so we can inject it into the HTML
|
||||||
const serverConfigString = JSON.stringify(JSON.stringify(getConfig()))
|
const config = getConfig()
|
||||||
|
const serverConfigString = JSON.stringify(JSON.stringify(config))
|
||||||
const configJS = `<script type="application/javascript">window.PeerTubeServerConfig = ${serverConfigString}</script>`
|
const configJS = `<script type="application/javascript">window.PeerTubeServerConfig = ${serverConfigString}</script>`
|
||||||
|
|
||||||
const tags = `
|
const tags = `
|
||||||
|
@ -113,10 +114,15 @@ app.use('/*', async function (req, res) {
|
||||||
|
|
||||||
const buffer = await readFile(join(__dirname, '../client/dist/index.html'))
|
const buffer = await readFile(join(__dirname, '../client/dist/index.html'))
|
||||||
|
|
||||||
indexHTML = buffer.toString()
|
let html = buffer.toString()
|
||||||
indexHTML = indexHTML.replace('</head>', tags + '</head>')
|
html = html.replace('</head>', tags + '</head>')
|
||||||
|
|
||||||
return res.send(indexHTML)
|
// Prevent caching a not ready yet configuration (because the indexer did not have time to run)
|
||||||
|
if (config.indexedHostsCount !== 0) {
|
||||||
|
indexHTML = html
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.send(html)
|
||||||
})
|
})
|
||||||
|
|
||||||
// ----------- Errors -----------
|
// ----------- Errors -----------
|
||||||
|
|
Loading…
Reference in New Issue