Gem Kingdom shop: Paid! page with refresh back to the game (CSP form-action blocked the cross-site 302)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-01 16:29:48 -05:00
parent be313e6202
commit 0e32a57424
+4 -1
View File
@@ -2568,7 +2568,10 @@ const server = http.createServer(async (req, res) => {
const rc = gkMint({ kind: 'gk-receipt', order: c.order, email: String(c.email).toLowerCase(), crowns: Number(c.crowns), credits: Number(c.credits), ref: out.campaignId }, 24 * 3600000);
gkCallback(c.cb, rc); // the server copy; the redirect below is the fast path
const ret = String(c.ret || '').startsWith(GK_URL() + '/') ? c.ret : GK_URL() + '/api/iap/receipt';
res.writeHead(302, { Location: ret + '?t=' + rc, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.gkshop', '', 0) }); return res.end();
// a 200 page, not a 302: CSP form-action 'self' blocks a form POST from redirecting to another site (the page just sat there)
const back = gkEsc(ret + '?t=' + rc);
res.setHeader('Set-Cookie', gkCookie('iap.gkshop', '', 0));
return gkPage(res, 200, 'Crowns added', '<meta http-equiv="refresh" content="1;url=' + back + '"><p class="sub">Gem Kingdom · Crown Shop</p><h1>Paid!</h1><div class="big">+' + Number(c.crowns).toLocaleString('en-US') + ' Crowns</div><p class="sub">Taking you back to your kingdom...</p><a class="btn" href="' + back + '">Back to Gem Kingdom</a>');
}
// -- PassiveDrip card on the Earn tab (Marty, 2026-10-01: "It's an earning site", not a game). Members see it when
// site config passivedripLive is 'on'; until then only the admin sees it, marked preview.