Spaces:
Paused
Paused
debug-logs: show cloudflare proxy env status explicitly
Browse filesAdd CLOUDFLARE PROXY STATUS section to /app/debug-logs:
- CLOUDFLARE_WORKERS_TOKEN presence (is proxy deployed?)
- CLOUDFLARE_PROXY_URL presence (are X calls being proxied?)
- NODE_OPTIONS value (is cloudflare-proxy.js injected?)
- /opt/cloudflare-proxy.js existence check
- cf-proxy-banner-shown marker
This reveals whether X oauth/access_token 500 errors are due to
HF datacenter IP block bypassed (or not) by the Cloudflare proxy.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1825 unmodified lines182618271828182918301831183218332 unmodified lines1836183718381839184018412 unmodified lines1844184518461847184818491850185118521825 unmodified lines].join("\n");const cfProxyLog = fs.existsSync("/tmp/huggingpost-cloudflare-proxy.env")? fs.readFileSync("/tmp/huggingpost-cloudflare-proxy.env", "utf8"): "No proxy env";const xCallbackLog = fs.existsSync("/tmp/x-oauth-callbacks.log")? fs.readFileSync("/tmp/x-oauth-callbacks.log", "utf8")2 unmodified linesconst out = [credSection,"","=== X OAUTH CALLBACKS (from health-server) ===",xCallbackLog,"",2 unmodified lines"","=== BACKEND OUT LOG (last 80 lines) ===",outLog,"","=== PROXY ENV ===",cfProxyLog,].join("\n");res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });res.end(out);1825 unmodified lines182618271828182918301831183218331834183518361837183818391840184118421843184418452 unmodified lines184818491850185118521853185418552 unmodified lines1858185918601861186218631825 unmodified lines].join("\n");const cfProxyLog = fs.existsSync("/tmp/huggingpost-cloudflare-proxy.env")? fs.readFileSync("/tmp/huggingpost-cloudflare-proxy.env", "utf8").replace(/(SECRET|TOKEN)=\S+/gi, "$1=(redacted)"): "(file not found β proxy not deployed; CLOUDFLARE_WORKERS_TOKEN not set?)";const cfProxySection = ["=== CLOUDFLARE PROXY STATUS ===",`CLOUDFLARE_WORKERS_TOKEN : ${process.env.CLOUDFLARE_WORKERS_TOKEN ? "β set (len=" + process.env.CLOUDFLARE_WORKERS_TOKEN.length + ")" : "β NOT SET β proxy never deployed, X traffic goes direct"}`,`CLOUDFLARE_PROXY_URL : ${process.env.CLOUDFLARE_PROXY_URL ? maskCred(process.env.CLOUDFLARE_PROXY_URL) : "β NOT SET β api.twitter.com calls NOT proxied"}`,`CLOUDFLARE_PROXY_DEBUG : ${process.env.CLOUDFLARE_PROXY_DEBUG || "(not set)"}`,`NODE_OPTIONS : ${process.env.NODE_OPTIONS || "(not set β cloudflare-proxy.js NOT loaded in backend!)"}`,`/opt/cloudflare-proxy.js : ${fs.existsSync("/opt/cloudflare-proxy.js") ? "β exists" : "β MISSING"}`,`/tmp/huggingpost-cloudflare-proxy.env contents:`,cfProxyLog,`cf-proxy-banner-shown : ${fs.existsSync("/tmp/.cf-proxy-banner-shown") ? "β (proxy init ran at least once)" : "(not found)"}`,].join("\n");const xCallbackLog = fs.existsSync("/tmp/x-oauth-callbacks.log")? fs.readFileSync("/tmp/x-oauth-callbacks.log", "utf8")2 unmodified linesconst out = [credSection,"",cfProxySection,"","=== X OAUTH CALLBACKS (from health-server) ===",xCallbackLog,"",2 unmodified lines"","=== BACKEND OUT LOG (last 80 lines) ===",outLog,].join("\n");res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });res.end(out);
health-server.js+16-5