somratpro Claude Sonnet 4.6 commited on
Commit
3b50174
Β·
1 Parent(s): 14458bf

debug-logs: show cloudflare proxy env status explicitly

Browse files

Add 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>

Files changed (1) hide show
  1. health-server.js +16 -5
health-server.js CHANGED
@@ -1826,8 +1826,20 @@ const server = http.createServer((req, res) => {
1826
  ].join("\n");
1827
 
1828
  const cfProxyLog = fs.existsSync("/tmp/huggingpost-cloudflare-proxy.env")
1829
- ? fs.readFileSync("/tmp/huggingpost-cloudflare-proxy.env", "utf8")
1830
- : "No proxy env";
 
 
 
 
 
 
 
 
 
 
 
 
1831
 
1832
  const xCallbackLog = fs.existsSync("/tmp/x-oauth-callbacks.log")
1833
  ? fs.readFileSync("/tmp/x-oauth-callbacks.log", "utf8")
@@ -1836,6 +1848,8 @@ const server = http.createServer((req, res) => {
1836
  const out = [
1837
  credSection,
1838
  "",
 
 
1839
  "=== X OAUTH CALLBACKS (from health-server) ===",
1840
  xCallbackLog,
1841
  "",
@@ -1844,9 +1858,6 @@ const server = http.createServer((req, res) => {
1844
  "",
1845
  "=== BACKEND OUT LOG (last 80 lines) ===",
1846
  outLog,
1847
- "",
1848
- "=== PROXY ENV ===",
1849
- cfProxyLog,
1850
  ].join("\n");
1851
  res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
1852
  res.end(out);
 
1826
  ].join("\n");
1827
 
1828
  const cfProxyLog = fs.existsSync("/tmp/huggingpost-cloudflare-proxy.env")
1829
+ ? fs.readFileSync("/tmp/huggingpost-cloudflare-proxy.env", "utf8").replace(/(SECRET|TOKEN)=\S+/gi, "$1=(redacted)")
1830
+ : "(file not found β€” proxy not deployed; CLOUDFLARE_WORKERS_TOKEN not set?)";
1831
+
1832
+ const cfProxySection = [
1833
+ "=== CLOUDFLARE PROXY STATUS ===",
1834
+ `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"}`,
1835
+ `CLOUDFLARE_PROXY_URL : ${process.env.CLOUDFLARE_PROXY_URL ? maskCred(process.env.CLOUDFLARE_PROXY_URL) : "βœ— NOT SET β€” api.twitter.com calls NOT proxied"}`,
1836
+ `CLOUDFLARE_PROXY_DEBUG : ${process.env.CLOUDFLARE_PROXY_DEBUG || "(not set)"}`,
1837
+ `NODE_OPTIONS : ${process.env.NODE_OPTIONS || "(not set β€” cloudflare-proxy.js NOT loaded in backend!)"}`,
1838
+ `/opt/cloudflare-proxy.js : ${fs.existsSync("/opt/cloudflare-proxy.js") ? "βœ“ exists" : "βœ— MISSING"}`,
1839
+ `/tmp/huggingpost-cloudflare-proxy.env contents:`,
1840
+ cfProxyLog,
1841
+ `cf-proxy-banner-shown : ${fs.existsSync("/tmp/.cf-proxy-banner-shown") ? "βœ“ (proxy init ran at least once)" : "(not found)"}`,
1842
+ ].join("\n");
1843
 
1844
  const xCallbackLog = fs.existsSync("/tmp/x-oauth-callbacks.log")
1845
  ? fs.readFileSync("/tmp/x-oauth-callbacks.log", "utf8")
 
1848
  const out = [
1849
  credSection,
1850
  "",
1851
+ cfProxySection,
1852
+ "",
1853
  "=== X OAUTH CALLBACKS (from health-server) ===",
1854
  xCallbackLog,
1855
  "",
 
1858
  "",
1859
  "=== BACKEND OUT LOG (last 80 lines) ===",
1860
  outLog,
 
 
 
1861
  ].join("\n");
1862
  res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
1863
  res.end(out);