diff --git a/server.js b/server.js index 7c6fcfc..452ff4e 100644 --- a/server.js +++ b/server.js @@ -1468,6 +1468,12 @@ const server = http.createServer(async (req, res) => { if (p === '/') { res.writeHead(302, { Location: 'https://' + SITE_HOST + '/', 'Cache-Control': 'no-store' }); return res.end(); } if (p === '/robots.txt') { res.writeHead(200, { 'Content-Type': 'text/plain' }); return res.end('User-agent: *\nAllow: /\n'); } if (p === '/assets/pt.js') return sendFile(res, path.join(PUBLIC_DIR, 'assets', 'pt.js')); + // page-builder media on the pages host (2026-10-30, Neville's lookfirst.page link): builder pages reference the niche + // library and member uploads by relative path, so both are served here with the main host's strict patterns and nothing else + let pim = /^\/niches\/([a-z0-9-]{1,80}\.(?:jpg|jpeg|png|webp|gif))$/.exec(p); + if (pim && (req.method === 'GET' || req.method === 'HEAD')) return sendFile(res, path.join(PUBLIC_DIR, 'niches', pim[1])); + pim = /^\/uploads\/([a-z0-9]{24}\.(?:png|jpg|webp|gif|mp4|webm))$/.exec(p); + if (pim && (req.method === 'GET' || req.method === 'HEAD')) return sendFile(res, path.join(UPLOADS_DIR, pim[1])); if (!/^\/p\/[a-z0-9-]{3,60}(\/lead)?$/i.test(p) && !/^\/api\/p\//.test(p) && !/^\/[a-z0-9-]{3,60}$/i.test(p)) { res.writeHead(404, { 'Content-Type': 'text/plain' }); return res.end('Not found'); } } let pm = /^\/p\/([a-z0-9-]{3,60})$/i.exec(p) || (isPagesHost(req) ? /^\/([a-z0-9-]{3,60})$/i.exec(p) : null);