From 2eb257c2a6760ae507d317758b21f94f1f46be31 Mon Sep 17 00:00:00 2001 From: 9qeklajc Date: Thu, 14 May 2026 15:47:59 +0200 Subject: [PATCH] fix home nav --- routstr/core/main.py | 17 +++++++++++++++-- routstr/proxy.py | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/routstr/core/main.py b/routstr/core/main.py index 535480a2..4c679e44 100644 --- a/routstr/core/main.py +++ b/routstr/core/main.py @@ -268,8 +268,21 @@ if UI_DIST_PATH.exists() and UI_DIST_PATH.is_dir(): ) @app.get("/", include_in_schema=False) - async def serve_root_ui() -> FileResponse: - return FileResponse(UI_DIST_PATH / "index.html") + async def serve_root_ui() -> StarletteResponse: + index = UI_DIST_PATH / "index.html" + if index.exists(): + return FileResponse(index) + # UI directory exists but the index page is missing — return a basic + # status payload so the home page never 404s. + from fastapi.responses import JSONResponse as _JSONResponse + + return _JSONResponse( + { + "name": global_settings.name, + "version": __version__, + "status": "running", + } + ) # Serve the App Router RSC payload for the home page. @app.get("/index.txt", include_in_schema=False) diff --git a/routstr/proxy.py b/routstr/proxy.py index 01bb753b..f416a302 100644 --- a/routstr/proxy.py +++ b/routstr/proxy.py @@ -2,7 +2,7 @@ import json from typing import Any from fastapi import APIRouter, Depends, HTTPException, Request -from fastapi.responses import Response, StreamingResponse +from fastapi.responses import JSONResponse, Response, StreamingResponse from sqlmodel import select from .algorithm import create_model_mappings @@ -174,6 +174,21 @@ async def proxy( # so that OpenAI-style endpoints work with or without the `v1/` prefix # (e.g. `/chat/completions` as well as `/v1/chat/completions`). if request.method == "GET" and not path.startswith(_API_PATH_PREFIXES): + # An empty path means the root `/` reached the catch-all because no + # explicit handler matched (e.g. the UI bundle is missing from the + # deploy). Return a small status payload instead of a 404 so that the + # home page never appears broken. + if not path: + from .core.version import __version__ + + return JSONResponse( + status_code=200, + content={ + "name": settings.name, + "version": __version__, + "status": "running", + }, + ) return build_not_found_response(request, path) headers = dict(request.headers)