1+ from fastapi .responses import FileResponse
12from fastapi .staticfiles import StaticFiles
23import sentry_sdk
3- from fastapi import FastAPI
4+ from fastapi import FastAPI , Path
45from fastapi .routing import APIRoute
56from starlette .middleware .cors import CORSMiddleware
67from apps .api import api_router
78from apps .system .middleware .auth import TokenMiddleware
89from common .core .config import settings
910
1011def custom_generate_unique_id (route : APIRoute ) -> str :
11- return f"{ route .tags [0 ]} -{ route .name } "
12+ tag = route .tags [0 ] if route .tags and len (route .tags ) > 0 else ""
13+ return f"{ tag } -{ route .name } "
1214
1315
1416if settings .SENTRY_DSN and settings .ENVIRONMENT != "local" :
@@ -32,7 +34,11 @@ def custom_generate_unique_id(route: APIRoute) -> str:
3234
3335app .add_middleware (TokenMiddleware )
3436app .include_router (api_router , prefix = settings .API_V1_STR )
35- app .mount ("/" , StaticFiles (directory = '../frontend/dist' ), name = "static" )
37+ app .mount ("/static" , StaticFiles (directory = '../frontend/dist' ), name = "static" )
38+
39+ @app .get ("/" , include_in_schema = False )
40+ async def read_index ():
41+ return FileResponse (path = "../frontend/dist/index.html" )
3642if __name__ == "__main__" :
3743 import uvicorn
3844 uvicorn .run ("main:app" , host = "0.0.0.0" , port = 8000 , reload = True )
0 commit comments