From 85ed0af7e4333a7c2948b28a8814e41319c4b016 Mon Sep 17 00:00:00 2001 From: James Pace Date: Sun, 1 Mar 2026 15:43:46 -0500 Subject: [PATCH] Play nice with react router. --- am_i_up/server.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/am_i_up/server.py b/am_i_up/server.py index 983930e..573872d 100644 --- a/am_i_up/server.py +++ b/am_i_up/server.py @@ -114,7 +114,7 @@ class Api: async def run(self): ui_share_directory = get_package_share_directory("am_i_up_ui") - ui_static_directory = ui_share_directory + "/dist" + ui_static_directory = ui_share_directory + "/dist/assets" app = web.Application() app.add_routes([ @@ -123,7 +123,10 @@ class Api: web.get('/api/build_info', self.build_info), web.get('/api/env', self.env), web.get('/api/status', self.status), - web.static("/", ui_static_directory) + web.static("/assets", ui_static_directory), + # we're not actually using key anywhere, but doing this allows react router + # to work correctly. + web.get("/{key:.*}", self.index) ]) url = "0.0.0.0" @@ -139,6 +142,11 @@ class Api: await asyncio.sleep(3600) await runner.cleanup() + async def index(self, request): + ui_share_directory = get_package_share_directory("am_i_up_ui") + ui_index_path = ui_share_directory + "/dist/index.html" + return web.FileResponse(ui_index_path) + async def ping(self, request): request_dict = await request.json() result = self._facts.do_ping(request_dict['address'])