INNER CODE UNIT · Python

serve_agent_installation_guide

ArcReel/ArcReel · server/app.py:710

async def serve_agent_installation_guide(request: Request) -> Response:
    """动态渲染 Agent 安装指引,将 {{BASE_URL}} 替换为实际服务地址(无需认证)。"""
    from fastapi.responses import PlainTextResponse

    template_path = PROJECT_ROOT / "public" / "agent-installation-guide.md"

    def _read() -> tuple[bool, str]:
        if not template_path.exists():
            return False, ""
        return True, template_path.read_text(encoding="utf-8")

    exists, template = await asyncio.to_thread(_read)
    if not exists:
        return PlainTextResponse("Agent 安装指引不存在", status_code=404)

    # 从请求推断 base URL;仅信任 x-forwarded-proto(反向代理标准头),
    # host 使用连接实际目标地址,不接受可被用户伪造的 x-forwarded-host。
    forwarded_proto = request.headers.get("x-forwarded-proto")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…