Files
gsfdc/server/app/core/client_ip.py
T
wuzilongandCursor 9c7c80e194 feat: 把估价智能体和部署配置提交到主分支
门户估价对话、会员与智能体账号,以及生产 Docker 部署一直停在工作区,远端主分支还没有这些改动。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-23 09:42:44 +08:00

15 lines
392 B
Python

from fastapi import Request
from app.core.config import get_settings
def client_ip(request: Request) -> str:
if get_settings().trust_proxy:
forwarded = request.headers.get("x-forwarded-for", "")
first = forwarded.split(",")[0].strip()
if first:
return first[:64]
if request.client is None:
return ""
return request.client.host or ""