Spaces:
Running on Zero
Running on Zero
Commit History
-
fix(shortener): set explicit User-Agent to bypass Cloudflare WAF
Hermes AgentThe AI QR Space's outgoing POST to URL_SHORTENER_API_URL was being blocked by Cloudflare WAF (Error 1010) because Python's urllib defaults to User-Agent 'Python-urllib/3.x', which Cloudflare classifies as a bot/script. Symptom (visible in the Space UI): 'short link unavailable: HTTP Error 403. Using normalized URL instead.' The shortener (qrcut.co) and its API key were both healthy. The block happens at the Cloudflare edge before the request reaches the upstream kvm9276 VPS. Same WAF error reproduced from this VM with curl and User-Agent 'Python-urllib/3.10' (Cloudflare ray-id a0a8299b1ed5d0d1, Error 1010). With any other UA, the same request returns 200. Fix: set an explicit User-Agent on the urllib request, shaped like a real operator/client, so Cloudflare does not flag it. Regression test: tests/inference/test_shortener_ua.py parses app.py textually and asserts (1) the request_headers dict is present, (2) it contains a User-Agent entry, (3) the UA is not the urllib default. Te…428df42
-
Upload 360 files
Verified signature762fbb3