From cab5181fd3d8159ba483fbb6d87a2b1fbf2379c4 Mon Sep 17 00:00:00 2001 From: ln0422 Date: Tue, 21 Apr 2026 12:15:58 +0800 Subject: [PATCH] branch1: root-path deployment variant with chat UI hidden - BASE_PATH="" for deployment at www.ityb.me root (no /careerbot prefix) - Root redirect route only registered when BASE is non-empty - Add secondary /careerbot/uploads mount for backward compat with trunk-uploaded photo URLs (shared DB scenario) - Hide chat FAB and chat panel on index.html (display:none) Co-Authored-By: Claude Opus 4.6 --- app/config.py | 2 +- app/main.py | 17 ++++++++++++----- templates/index.html | 6 +++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/config.py b/app/config.py index 9db3634..8c86401 100644 --- a/app/config.py +++ b/app/config.py @@ -8,7 +8,7 @@ class Settings(BaseSettings): ALGORITHM: str = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES: int = 480 UPLOAD_DIR: str = "./uploads" - BASE_PATH: str = "/careerbot" + BASE_PATH: str = "" model_config = {"env_file": ".env", "env_file_encoding": "utf-8"} diff --git a/app/main.py b/app/main.py index c27084b..d41e4ce 100644 --- a/app/main.py +++ b/app/main.py @@ -10,7 +10,7 @@ from app.models import AdminUser, Profile from app.routers import auth, public, admin, chat from app.routers.auth import hash_password -BASE = settings.BASE_PATH +BASE = settings.BASE_PATH # "" for root deployment, or "/careerbot" for subpath app = FastAPI(title="CareerBot", description="Personal Career Showcase with AI Assistant") @@ -19,6 +19,12 @@ app.mount(f"{BASE}/static", StaticFiles(directory="app/static"), name="static") os.makedirs(settings.UPLOAD_DIR, exist_ok=True) app.mount(f"{BASE}/uploads", StaticFiles(directory=settings.UPLOAD_DIR), name="uploads") +# When BASE="" and DB is shared with a /careerbot deployment, photo_url values +# stored by the sibling deployment begin with "/careerbot/uploads/...". +# Add a secondary mount so those URLs keep resolving here. +if BASE == "": + app.mount("/careerbot/uploads", StaticFiles(directory=settings.UPLOAD_DIR), name="uploads_legacy") + # Include routers with BASE_PATH prefix app.include_router(auth.router, prefix=BASE) app.include_router(public.router, prefix=BASE) @@ -30,10 +36,11 @@ admin.templates.env.globals["base"] = BASE public.templates.env.globals["base"] = BASE -# Root redirect to CareerBot -@app.get("/") -def root_redirect(): - return RedirectResponse(url=f"{BASE}/", status_code=302) +# Root redirect only needed when deployed under a subpath (otherwise "/" is already the app root) +if BASE: + @app.get("/") + def root_redirect(): + return RedirectResponse(url=f"{BASE}/", status_code=302) @app.on_event("startup") diff --git a/templates/index.html b/templates/index.html index 3267b1e..6546166 100644 --- a/templates/index.html +++ b/templates/index.html @@ -34,8 +34,8 @@
- - -
+