openfoodfacts_proxy.routes.common
source module openfoodfacts_proxy.routes.common
Functions
-
get_client_ip — Extract the client IP, respecting X-Forwarded-For and X-Real-IP when present.
-
build_upstream_url — Build the upstream URL preserving the incoming query string.
-
redirect_to_upstream — Return a redirect to the upstream OFF API.
source get_client_ip(request: Request) → str
Extract the client IP, respecting X-Forwarded-For and X-Real-IP when present.
source build_upstream_url(request: Request, upstream_path: str | None = None) → str
Build the upstream URL preserving the incoming query string.
source redirect_to_upstream(request: Request, upstream_path: str | None = None, *, status_code: int = 307) → RedirectResponse
Return a redirect to the upstream OFF API.
Redirecting keeps the effective OFF rate limit tied to the client IP instead of collapsing all traffic behind this server's IP address.