Spaces:
Sleeping
Sleeping
Commit History
-
Fix rate limiting: key off X-Forwarded-For, not the proxy peer address
Claude +1: Claude Sonnet 5Unverified signatureLive-tested against the deployed HF Space right after the previous merge: fired 25 rapid requests against a 20/60s limit and every single one returned 200. Root cause: the Space is only reachable through Hugging Face's own reverse proxy, so request.client.host (what the rate limiter was keying on) is the proxy's own connecting address, not the real caller - so requests either share one wrong bucket or never accumulate against a consistent key at all. This is also why the mocked integration tests never caught it: Starlette's TestClient always presents a fixed synthetic peer address, so it could validate the RateLimiter's own logic (already covered) but not this deployment-specific IP-detection gap. Fix: app/main.py now derives the client key via a new get_client_ip() helper that prefers X-Forwarded-For's left-most entry - trustworthy here since the container has no other ingress path. Added a TDD-first regression test (test_rate_limit_keys_on_x_forwarded_for_not_the_proxy_peer) that r…4cef71e -
Add rate limiting, tests, better extraction, and HF auto-deploy
Claude +1: Claude Sonnet 5Unverified signatureBuilt via TDD: each module below was preceded by a failing test suite in tests/, then implemented to pass it (66 tests total). - Restructure main.py into app/ modules (config, security, rate_limit, cache, extractor, scraper, main) instead of one file. - Add a per-IP sliding-window rate limiter and an optional API key gate on /scrape, closing the abuse/cost gap on an endpoint that launches a real browser per call. - Replace the regex-based ad/nav-stripping heuristic with trafilatura, a readability-style extractor that identifies boilerplate instead of pattern-matching class/id substrings (fewer false-positive removals of legitimate content). - Add a short-TTL in-memory cache so repeat requests for the same URL skip re-rendering with a full browser. - Add .github/workflows/ci-deploy.yml: runs the test suite on every push/PR, then pushes to the Hugging Face Space's main branch (needs an HF_TOKEN repository secret) so deploys no longer require a manual git push. - Upda…ebab0e2