← back to Agent Cabinet
front-page-audit/screens/crcp/repro/serve-fb.cjs
6 lines
const http=require("http"),fs=require("fs");const SID=process.env.CRCP_SID||"(set CRCP_SID env var)";
http.createServer((req,res)=>{const p=req.url;
if(p==="/"||p.startsWith("/?")){res.writeHead(200,{"Content-Type":"text/html"});res.end(fs.readFileSync(__dirname+"/real-index-fallback.html"));return;}
const u=new URL("http://127.0.0.1:9912"+p);const pr=http.request({hostname:u.hostname,port:u.port,path:u.pathname+u.search,method:req.method,headers:{Cookie:"crcp_sid="+SID}},(r2)=>{res.writeHead(r2.statusCode,r2.headers);r2.pipe(res);});pr.on("error",e=>{res.writeHead(502);res.end(e.message)});req.pipe(pr);
}).listen(0,"127.0.0.1",function(){console.log("FBPORT="+this.address().port)});