11# mypy: disable - error - code = "no-untyped-def,misc"
22import pathlib
3- from fastapi import FastAPI , Request , Response
3+ from fastapi import FastAPI , Response
44from fastapi .staticfiles import StaticFiles
5- import fastapi .exceptions
65
76# Define the FastAPI app
87app = FastAPI ()
@@ -18,7 +17,6 @@ def create_frontend_router(build_dir="../frontend/dist"):
1817 A Starlette application serving the frontend.
1918 """
2019 build_path = pathlib .Path (__file__ ).parent .parent .parent / build_dir
21- static_files_path = build_path / "assets" # Vite uses 'assets' subdir
2220
2321 if not build_path .is_dir () or not (build_path / "index.html" ).is_file ():
2422 print (
@@ -36,21 +34,7 @@ async def dummy_frontend(request):
3634
3735 return Route ("/{path:path}" , endpoint = dummy_frontend )
3836
39- build_dir = pathlib .Path (build_dir )
40-
41- react = FastAPI (openapi_url = "" )
42- react .mount (
43- "/assets" , StaticFiles (directory = static_files_path ), name = "static_assets"
44- )
45-
46- @react .get ("/{path:path}" )
47- async def handle_catch_all (request : Request , path : str ):
48- fp = build_path / path
49- if not fp .exists () or not fp .is_file ():
50- fp = build_path / "index.html"
51- return fastapi .responses .FileResponse (fp )
52-
53- return react
37+ return StaticFiles (directory = build_path , html = True )
5438
5539
5640# Mount the frontend under /app to not conflict with the LangGraph API routes
0 commit comments