From d2f9557f95e48a5822e875ccbf0b18dc995ef409 Mon Sep 17 00:00:00 2001 From: Theodore Dubois Date: Wed, 28 Dec 2022 16:10:56 -0800 Subject: [PATCH] Fix server crash --- server/routes/admin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/routes/admin.js b/server/routes/admin.js index eb6bd8dcb..42c7d745c 100644 --- a/server/routes/admin.js +++ b/server/routes/admin.js @@ -124,7 +124,7 @@ router.get('/admin/users', handleErrorAsync(async (req, res) => { }); })); -const fetchStats = async () => { +const fetchStats = async (req) => { if (fs.existsSync(statsFile)) { return JSON.parse(fs.readFileSync(statsFile)); } @@ -139,7 +139,7 @@ router.get('/admin/stats', handleErrorAsync(async (req, res) => { return res.status(401).json({error: 'Unauthorised'}); } - const stats = await fetchStats(); + const stats = await fetchStats(req); for (let locale in stats.locales) { if (stats.locales.hasOwnProperty(locale) && !req.isGranted('panel', locale)) { @@ -151,7 +151,7 @@ router.get('/admin/stats', handleErrorAsync(async (req, res) => { })); router.get('/admin/stats-public', handleErrorAsync(async (req, res) => { - const statsAll = await fetchStats(); + const statsAll = await fetchStats(req); const plausible = statsAll.home.plausible; const stats = {