From 66384c1795cc0134631a182ec9ff3dc6789ffbda Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Mon, 15 Jul 2024 22:09:51 -0500 Subject: [PATCH] fix(server): only mount the static files if the _next directory exists --- rnd/autogpt_server/autogpt_server/server/server.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rnd/autogpt_server/autogpt_server/server/server.py b/rnd/autogpt_server/autogpt_server/server/server.py index 03f3f199b6..762b37c21f 100644 --- a/rnd/autogpt_server/autogpt_server/server/server.py +++ b/rnd/autogpt_server/autogpt_server/server/server.py @@ -203,11 +203,13 @@ class AgentServer(AppService): #! DO NOT ADD ANY FUNCTIONS BETWEEN THESE FUNCTIONS #! DO NOT REMOVE ANY OF THESE FUNCTIONS #! YOU WILL BREAK THE FRONTEND PACKAGED WITH THE SERVER - app.mount( - path="/_next", - app=SPAStaticFiles(directory=get_frontend_path() / "_next", html=True), - name="frontend", - ) + + if os.path.exists(get_frontend_path() / "_next"): + app.mount( + path="/_next", + app=SPAStaticFiles(directory=get_frontend_path() / "_next", html=True), + name="frontend", + ) @app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): # type: ignore