diff --git a/netdeals.js b/netdeals.js index e708583..f24c466 100644 --- a/netdeals.js +++ b/netdeals.js @@ -45,7 +45,8 @@ function withLocal(body, self) { }).filter(Boolean) })) }; } // GET /api/network-deals: public, short cache, the same answer on every page. self = this site's network id (NETWORK_SITE_ID). -function handle(req, res, self) { +async function handle(req, res, self) { + if (!cache.at) { try { await refresh(); } catch (e) {} } // first ask after a boot waits for the hub once (2.5 s cap) const me = String(self || process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); const body = Object.assign({ self: me }, withLocal(current(), me)); res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=60', 'X-Content-Type-Options': 'nosniff' });