1
1
# mypy: disable - error - code = "no-untyped-def,misc"
2
2
import pathlib
3
- from fastapi import FastAPI , Request , Response
3
+ from fastapi import FastAPI , Response
4
4
from fastapi .staticfiles import StaticFiles
5
- import fastapi .exceptions
6
5
7
6
# Define the FastAPI app
8
7
app = FastAPI ()
@@ -18,7 +17,6 @@ def create_frontend_router(build_dir="../frontend/dist"):
18
17
A Starlette application serving the frontend.
19
18
"""
20
19
build_path = pathlib .Path (__file__ ).parent .parent .parent / build_dir
21
- static_files_path = build_path / "assets" # Vite uses 'assets' subdir
22
20
23
21
if not build_path .is_dir () or not (build_path / "index.html" ).is_file ():
24
22
print (
@@ -36,21 +34,7 @@ async def dummy_frontend(request):
36
34
37
35
return Route ("/{path:path}" , endpoint = dummy_frontend )
38
36
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 )
54
38
55
39
56
40
# Mount the frontend under /app to not conflict with the LangGraph API routes
0 commit comments