@davoodmehraban89 / Aram-2 Mirror · read-only / commits / 0c5dcb1
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 4, 14:15 UTC

fix(pilot): serve workbench directly at root (no redirect) for proxy safety

The preview proxy can mishandle the / -> /pilot/ redirect hop. Serve the workbench HTML directly at / with absolute asset paths so the app loads in one request at both / and /pilot/. Update the root test accordingly. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>

davoodmehraban89 committed Dec 3, 2026 at 07:58 UTC 0c5dcb16cc27d809ebb011a868e562a620c766c1
3 files changed +10 -8
backend/src/aram_backend/main.py
+5 -3
@@ -1,7 +1,7 @@
1 from pathlib import Path
2
3 from fastapi import FastAPI
4 -from fastapi.responses import RedirectResponse
4 +from fastapi.responses import HTMLResponse
5 from fastapi.staticfiles import StaticFiles
6
7 from aram_backend import __version__
@@ -21,8 +21,10 @@ app.mount(
21
22
23 @app.get("/", include_in_schema=False)
24 -def root() -> RedirectResponse:
25 - return RedirectResponse(url="/pilot/")
24 +def root() -> HTMLResponse:
25 + """Serve the workbench directly at the root (no redirect, proxy-safe)."""
26 + page = Path(__file__).parent / "static" / "pilot" / "index.html"
27 + return HTMLResponse(page.read_text(encoding="utf-8"))
28
29
30 @app.get("/api/v1/health", response_model=HealthResponse, tags=["system"])
backend/src/aram_backend/static/pilot/index.html
+2 -2
@@ -8,7 +8,7 @@
8 <meta name="apple-mobile-web-app-capable" content="yes">
9 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
10 <title>آرام — میز کار پایلوت</title>
11 - <link rel="stylesheet" href="styles.css">
11 + <link rel="stylesheet" href="/pilot/styles.css">
12 <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='80' font-size='80'>📊</text></svg>">
13 </head>
14 <body>
@@ -125,6 +125,6 @@
125 خروجی پیش‌نویس کاری است؛ برای گزارشگری رسمی استفاده نکنید.
126 </footer>
127
128 - <script src="app.js"></script>
128 + <script src="/pilot/app.js"></script>
129 </body>
130 </html>
backend/tests/test_pilot_api.py
+3 -3
@@ -18,10 +18,10 @@ def test_meta_exposes_explicit_sign_policy(client):
18 assert body["section_policy"]["IS"] == {"Revenue": -1, "Expenses": 1}
19
20
21 -def test_root_redirects_to_workbench_and_ui_is_served(client):
21 +def test_root_serves_workbench_directly_and_ui_is_served(client):
22 response = client.get("/", follow_redirects=False)
23 - assert response.status_code in {302, 307}
24 - assert response.headers["location"] == "/pilot/"
23 + assert response.status_code == 200
24 + assert "میز کار پایلوت" in response.text
25 page = client.get("/pilot/")
26 assert page.status_code == 200
27 assert "میز کار پایلوت" in page.text