--- server.py +++ server.py @@ -2529,6 +2529,20 @@ except Exception as e: raise HTTPException(status_code=502, detail=f"Failed to fetch pattern posts: {e}") +@app.get("/api/pattern/itemsets") +async def proxy_pattern_itemsets(execution_id: int): + """代理获取 itemsets,避免前端直接请求外部域名""" + try: + async with httpx.AsyncClient(timeout=30.0) as client: + resp = await client.get( + f"https://pattern.aiddit.com/api/pattern/itemsets?execution_id={execution_id}&page_size=1000", + ) + resp.raise_for_status() + return resp.json() + except httpx.HTTPStatusError as e: + raise HTTPException(status_code=e.response.status_code, detail="Pattern itemsets API returned an error") + except Exception as e: + raise HTTPException(status_code=502, detail=f"Failed to fetch pattern itemsets: {e}") @app.get("/") def frontend():