You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2025/09/11 01:00:10 UTC
(superset) 01/01: fix: add subdirectory deployment support for Swagger UI and app icon
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch subdirectories
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 02f49538e4b27e9862c155ef2d160167bd857658
Author: Elizabeth Thompson <es...@gmail.com>
AuthorDate: Wed Sep 10 17:58:08 2025 -0700
fix: add subdirectory deployment support for Swagger UI and app icon
This change fixes two issues with subdirectory deployments:
1. Adds /swagger/v1 endpoint that redirects to Flask-AppBuilder's swagger
endpoint with proper APPLICATION_ROOT prefix for subdirectory deployments
2. Fixes APP_ICON path to include subdirectory prefix when deployed in
a subdirectory
The swagger fix follows the same pattern as other Superset routes using
Flask-AppBuilder @expose decorator and @has_access for authentication.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <no...@anthropic.com>
---
superset/app.py | 6 ++++++
superset/views/core.py | 22 ++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/superset/app.py b/superset/app.py
index a0517b773c..e7237c29c8 100644
--- a/superset/app.py
+++ b/superset/app.py
@@ -68,6 +68,12 @@ def create_app(
# value of app_root so things work out of the box
if not app.config["STATIC_ASSETS_PREFIX"]:
app.config["STATIC_ASSETS_PREFIX"] = app_root
+ # Fix APP_ICON path for subdirectory deployments
+ if (
+ app.config.get("APP_ICON", "").startswith("/static/")
+ and app_root != "/"
+ ):
+ app.config["APP_ICON"] = f"{app_root}{app.config['APP_ICON']}"
if app.config["APPLICATION_ROOT"] == "/":
app.config["APPLICATION_ROOT"] = app_root
diff --git a/superset/views/core.py b/superset/views/core.py
index e836b8b546..f03b6652f8 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -938,3 +938,25 @@ class Superset(BaseSupersetView):
@deprecated(new_target="/sqllab/history")
def sqllab_history(self) -> FlaskResponse:
return redirect(url_for("SqllabView.history"))
+
+ @has_access
+ @expose("/swagger/v1")
+ def swagger_ui_redirect(self) -> FlaskResponse:
+ """
+ Redirect to Flask-AppBuilder's swagger UI with proper APPLICATION_ROOT support.
+
+ This fixes the issue where /swagger/v1 doesn't work in subdirectory deployments
+ by redirecting to Flask-AppBuilder's existing swagger endpoint.
+ """
+ # Check if swagger is enabled
+ if not app.config.get("FAB_API_SWAGGER_UI", False):
+ abort(404, "Swagger UI is disabled")
+
+ # Get the application root
+ app_root = app.config.get("APPLICATION_ROOT", "/").rstrip("/")
+
+ # Flask-AppBuilder's swagger endpoint is typically /api/v1/swagger
+ # Redirect to it with the proper application root prefix
+ fab_swagger_path = f"{app_root}/api/v1/swagger"
+
+ return redirect(fab_swagger_path)