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:
@@ -24,7 +24,7 @@
|
||||
if (soon.length) S.innerHTML = '<h2 class="gsec">Opening next</h2><div class="ggrid">' + soon.map(card).join('') + '</div>';
|
||||
}).catch(function () { document.getElementById('gEmpty').hidden = false; });
|
||||
// featured warriors from the PolyWarriors market (2026-10-10): the rarest listings, with the forged art
|
||||
fetch('https://www.polywarriors.com/api/public/featured').then(function (r) { return r.json(); }).then(function (d) {
|
||||
fetch('/api/public/pw-featured').then(function (r) { return r.json(); }).then(function (d) {
|
||||
var f = (d && d.featured) || []; if (!f.length) return; var S = document.getElementById('gSoon'); var host = document.createElement('div'); host.id = 'gFeatured';
|
||||
host.innerHTML = '<h2 class="gsec">From the PolyWarriors market <small style="letter-spacing:0;text-transform:none;font-size:11px"> <a href="' + esc(d.market) + '" target="_blank" rel="noopener">open the market</a></small></h2><div class="fgrid">' + f.map(function (x) {
|
||||
return '<a class="fcard" href="' + esc(x.url) + '" target="_blank" rel="noopener" style="--rc:' + esc(x.color) + '"><div class="fpic"><img src="' + esc(x.image) + '" alt="" loading="lazy"><span class="ftag">' + esc(x.rarity) + '</span>' + (x.forSale ? '<span class="fsale">For sale</span>' : '') + '</div><div class="fb"><b>' + esc(x.name) + ' #' + String(x.serial).padStart(4, '0') + '</b>' + (x.forge ? '<small>Forged ' + esc(x.forge.grade) + ' ' + esc(x.forge.score) + '</small>' : '') + (x.forSale ? '<span class="fp">' + esc(x.price) + ' POL</span>' : '') + '</div></a>'; }).join('') + '</div>';
|
||||
|
||||
+1
-1
@@ -78,6 +78,6 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261007a"></script><script src="/assets/games-page.js?v=20261010b"></script>
|
||||
<script src="/assets/common.js?v=20261007a"></script><script src="/assets/games-page.js?v=20261010c"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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