Share links served in place with og:url carrying the ref (Facebook was dropping the name); portrait 9:16 teaser for TikTok/Reels/Shorts/Facebook; test updated

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-21 08:09:04 -05:00
parent a1e846e3b5
commit 48c334dd73
5 changed files with 12 additions and 6 deletions
+10 -4
View File
@@ -163,11 +163,17 @@ const server = http.createServer(async (req, res) => {
if (curtained(req, res, u)) return;
// a member's share link: /?r=<their IAP username or id> becomes a 30-day cookie; the landing then
// sends sign-ups to instantadpay.com/join/<ref>, so IAP's own last-touch sponsor rule applies
// Served in place, not redirected (Marty, 2026-09-21): Facebook's crawler follows redirects and canonicalizes a
// share to og:url, so a redirect to the bare home page lost the member's name on every share. og:url carries
// the ref; the cookie rides on the same response.
if (p === '/' && u.searchParams.get('r')) {
const r = String(u.searchParams.get('r')).trim().slice(0, 40); u.searchParams.delete('r');
const h = { Location: '/' + (u.searchParams.toString() ? '?' + u.searchParams : ''), 'Cache-Control': 'no-store' };
if (/^[A-Za-z0-9_.-]{1,40}$/.test(r)) h['Set-Cookie'] = 'ph.ref=' + encodeURIComponent(r) + '; Path=/; Max-Age=2592000; SameSite=Lax; Secure';
res.writeHead(302, h); return res.end();
const r = String(u.searchParams.get('r')).trim().slice(0, 40);
const ok = /^[A-Za-z0-9_.-]{1,40}$/.test(r);
let html = fs.readFileSync(path.join(PUBLIC_DIR, 'index.html'), 'utf8');
if (ok) html = html.replace('<meta property="og:url" content="https://polhunter.com/">', '<meta property="og:url" content="https://polhunter.com/?r=' + encodeURIComponent(r) + '">');
const h = Object.assign({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' }, SEC);
if (ok) h['Set-Cookie'] = 'ph.ref=' + encodeURIComponent(r) + '; Path=/; Max-Age=2592000; SameSite=Lax; Secure';
res.writeHead(200, h); return res.end(html);
}
// ---- sign-in by hand-off from InstantAdPay