diff --git a/server.ts b/server.ts index d930977..ad7eb87 100644 --- a/server.ts +++ b/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 - const serverConfigString = JSON.stringify(JSON.stringify(getConfig())) + const config = getConfig() + const serverConfigString = JSON.stringify(JSON.stringify(config)) const configJS = `` const tags = ` @@ -113,10 +114,15 @@ app.use('/*', async function (req, res) { const buffer = await readFile(join(__dirname, '../client/dist/index.html')) - indexHTML = buffer.toString() - indexHTML = indexHTML.replace('', tags + '') + let html = buffer.toString() + html = html.replace('', tags + '') - 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 -----------