From 5bfdb72019ed954fcf93f14ead08a28e28f343ca Mon Sep 17 00:00:00 2001 From: naaive <73341653+naaive@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:51:23 +0800 Subject: [PATCH] chore: fix health API (#21) chore: fix assets path conflict --- src/openagent/app.py | 15 ++++++++------- src/widget/vite.config.ts | 9 ++++++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/openagent/app.py b/src/openagent/app.py index a24a0e4e..8cbf815b 100644 --- a/src/openagent/app.py +++ b/src/openagent/app.py @@ -23,6 +23,12 @@ allow_headers=["*"], ) + +@app.get("/health", status_code=status.HTTP_200_OK) +async def health_check(): + return JSONResponse(content={"status": "ok"}) + + app.include_router(onboarding_router) app.include_router(chat_router) app.include_router(session_router) @@ -34,11 +40,6 @@ async def swap_root(): return FileResponse(os.path.join("dist", "index.html")) -app.mount("/assets", StaticFiles(directory="dist/assets"), name="widget") +app.mount("/static", StaticFiles(directory="dist/static"), name="widget") -mount_chainlit(app=app, target="openagent/ui/app.py", path="/ui") - - -@app.get("/health", status_code=status.HTTP_200_OK) -async def health_check(): - return JSONResponse(content={"status": "ok"}) +mount_chainlit(app=app, target="openagent/ui/app.py", path="") diff --git a/src/widget/vite.config.ts b/src/widget/vite.config.ts index f6115b38..f0751fcb 100644 --- a/src/widget/vite.config.ts +++ b/src/widget/vite.config.ts @@ -10,7 +10,14 @@ export default defineConfig({ target: 'esnext', }, build: { - outDir: '../dist' + outDir: '../dist', + rollupOptions: { + output: { + assetFileNames: 'static/[name].[hash].[ext]', + chunkFileNames: 'static/[name].[hash].js', + entryFileNames: 'static/[name].[hash].js', + } + } }, server: {