Games page: featured PolyWarriors listings come through a same-origin proxy (/api/public/pw-featured, 60 s cache); the page CSP blocked the direct call
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -3425,6 +3425,11 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
// -- cross-promo strip (2026-10-03): the list every game reads, and the counted hop between games
|
||||
// -- the public games page (2026-10-10, Marty: a page to send people): every game, open ones first, dated ones after
|
||||
// featured PolyWarriors listings for the games page, fetched server-side (the page CSP allows no cross-origin calls), cached 60 s
|
||||
if (p === '/api/public/pw-featured' && req.method === 'GET') {
|
||||
const now = Date.now(); if (!global.__pwFeat || now - global.__pwFeat.at > 60000) { try { const r = await fetch(String(process.env.PW_URL || 'https://www.polywarriors.com').replace(/\/+$/, '') + '/api/public/featured', { signal: AbortSignal.timeout(6000) }); global.__pwFeat = { at: now, body: r.ok ? await r.json() : { featured: [] } }; } catch (e) { global.__pwFeat = { at: now, body: { featured: [] } }; } }
|
||||
return json(res, 200, global.__pwFeat.body, { 'Cache-Control': 'public, max-age=60' });
|
||||
}
|
||||
if (p === '/api/public/games/all' && req.method === 'GET') {
|
||||
const sc = siteConfig(); const live = new Set(String(sc.gamesLive == null ? 'polhunter' : sc.gamesLive).split(',').map(x => x.trim().toLowerCase()).filter(Boolean));
|
||||
const day = todayCT(), S = STRIP(); const lbl = (d, back) => { const t = new Date(d + 'T12:00:00Z'); if (back) t.setUTCDate(t.getUTCDate() - 1); return t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }); };
|
||||
|
||||
Reference in New Issue
Block a user