From 128e36536ac0fc4c30dcb2d84cfc33f20d1fa7a9 Mon Sep 17 00:00:00 2001 From: philschmid Date: Tue, 10 Jun 2025 07:51:35 +0000 Subject: [PATCH] update react serving part --- backend/src/agent/app.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/backend/src/agent/app.py b/backend/src/agent/app.py index 090e2ed..f20f6ed 100644 --- a/backend/src/agent/app.py +++ b/backend/src/agent/app.py @@ -1,8 +1,7 @@ # mypy: disable - error - code = "no-untyped-def,misc" import pathlib -from fastapi import FastAPI, Request, Response +from fastapi import FastAPI, Response from fastapi.staticfiles import StaticFiles -import fastapi.exceptions # Define the FastAPI app app = FastAPI() @@ -18,7 +17,6 @@ def create_frontend_router(build_dir="../frontend/dist"): A Starlette application serving the frontend. """ build_path = pathlib.Path(__file__).parent.parent.parent / build_dir - static_files_path = build_path / "assets" # Vite uses 'assets' subdir if not build_path.is_dir() or not (build_path / "index.html").is_file(): print( @@ -36,21 +34,7 @@ def create_frontend_router(build_dir="../frontend/dist"): return Route("/{path:path}", endpoint=dummy_frontend) - build_dir = pathlib.Path(build_dir) - - react = FastAPI(openapi_url="") - react.mount( - "/assets", StaticFiles(directory=static_files_path), name="static_assets" - ) - - @react.get("/{path:path}") - async def handle_catch_all(request: Request, path: str): - fp = build_path / path - if not fp.exists() or not fp.is_file(): - fp = build_path / "index.html" - return fastapi.responses.FileResponse(fp) - - return react + return StaticFiles(directory=build_path, html=True) # Mount the frontend under /app to not conflict with the LangGraph API routes