diff --git a/conda-store-server/conda_store_server/_internal/server/app.py b/conda-store-server/conda_store_server/_internal/server/app.py index 7e23361d8..006f936f1 100644 --- a/conda-store-server/conda_store_server/_internal/server/app.py +++ b/conda-store-server/conda_store_server/_internal/server/app.py @@ -293,15 +293,32 @@ async def exception_handler(request, exc): # docker registry api specification does not support a url_prefix app.include_router(views.router_registry) - if self.enable_ui: + if self.enable_metrics: app.include_router( - views.router_ui, - prefix=trim_slash(self.url_prefix) + "/admin", + views.router_metrics, + prefix=trim_slash(self.url_prefix), ) + if self.additional_routes: + for path, method, func in self.additional_routes: + getattr(app, method)(path, name=func.__name__)(func) + + if isinstance(self.conda_store.storage, storage.LocalStorage): + self.conda_store.storage.storage_url = ( + f"{trim_slash(self.url_prefix)}/storage" + ) + app.mount( + self.conda_store.storage.storage_url, + StaticFiles(directory=self.conda_store.storage.storage_path), + name="static-storage", + ) + + # This needs to come at the end because if the UI is enabled, + # it becomes the catch all route + if self.enable_ui: app.include_router( - views.router_conda_store_ui, - prefix=trim_slash(self.url_prefix), + views.router_ui, + prefix=trim_slash(self.url_prefix) + "/admin", ) # serving static files @@ -336,26 +353,12 @@ async def favicon(): ) ) - if self.enable_metrics: + # Put this at the very end app.include_router( - views.router_metrics, + views.router_conda_store_ui, prefix=trim_slash(self.url_prefix), ) - if self.additional_routes: - for path, method, func in self.additional_routes: - getattr(app, method)(path, name=func.__name__)(func) - - if isinstance(self.conda_store.storage, storage.LocalStorage): - self.conda_store.storage.storage_url = ( - f"{trim_slash(self.url_prefix)}/storage" - ) - app.mount( - self.conda_store.storage.storage_url, - StaticFiles(directory=self.conda_store.storage.storage_path), - name="static-storage", - ) - return app def _check_worker(self, delay=5): diff --git a/conda-store-server/conda_store_server/_internal/server/templates/conda-store-ui.html b/conda-store-server/conda_store_server/_internal/server/templates/conda-store-ui.html index 2a05a49db..3ce8ffce0 100644 --- a/conda-store-server/conda_store_server/_internal/server/templates/conda-store-ui.html +++ b/conda-store-server/conda_store_server/_internal/server/templates/conda-store-ui.html @@ -28,8 +28,8 @@ REACT_APP_URL_BASENAME: new URL("{{ url_for('get_conda_store_ui') }}").pathname }; - - + + diff --git a/conda-store-server/conda_store_server/_internal/server/views/conda_store_ui.py b/conda-store-server/conda_store_server/_internal/server/views/conda_store_ui.py index ece7d8a74..c7a32d1b4 100644 --- a/conda-store-server/conda_store_server/_internal/server/views/conda_store_ui.py +++ b/conda-store-server/conda_store_server/_internal/server/views/conda_store_ui.py @@ -9,10 +9,11 @@ router_conda_store_ui = APIRouter(tags=["conda-store-ui"]) - @router_conda_store_ui.get("/") +@router_conda_store_ui.get("/{full_path:path}") async def get_conda_store_ui( request: Request, + full_path: str, templates=Depends(dependencies.get_templates), ): context = {