eschutho opened a new pull request, #35098: URL: https://github.com/apache/superset/pull/35098
## Summary This PR fixes two issues with subdirectory deployments in Apache Superset: ### 1. Swagger UI subdirectory support - Adds `/swagger/v1` endpoint that properly redirects to Flask-AppBuilder's swagger endpoint - Handles `APPLICATION_ROOT` configuration to construct correct subdirectory paths - Uses Flask-AppBuilder patterns (`@expose`, `@has_access`) for consistency with other Superset routes ### 2. App icon subdirectory support - Fixes `APP_ICON` path to include subdirectory prefix when `APPLICATION_ROOT` is not "/" - Automatically prefixes `/static/` paths with the configured subdirectory - Preserves custom icon paths that don't start with `/static/` ## Problem When Superset is deployed in a subdirectory (e.g., `https://example.com/superset/`), certain features don't work correctly: - `/swagger/v1` endpoint returns 404 because it doesn't account for the subdirectory prefix - App icon (`APP_ICON`) uses hardcoded `/static/` paths that don't work in subdirectory deployments ## Solution ### Swagger Fix Added a redirect endpoint in `superset/views/core.py` that: - Reads `APPLICATION_ROOT` configuration - Constructs proper redirect path: `{APPLICATION_ROOT}/api/v1/swagger` - Respects `FAB_API_SWAGGER_UI` security setting **Example behavior:** - Default deployment: `/swagger/v1` → `/api/v1/swagger` - Subdirectory deployment: `/swagger/v1` → `/superset/api/v1/swagger` ### App Icon Fix Added logic in `superset/app.py` that: - Automatically prefixes `APP_ICON` paths that start with `/static/` - Only applies the fix for subdirectory deployments (`app_root != "/"`) - Preserves custom icon paths **Example behavior:** - Default: `APP_ICON = "/static/assets/images/logo.png"` → unchanged - Subdirectory: `APP_ICON = "/static/assets/images/logo.png"` → `"/superset/static/assets/images/logo.png"` ## Test plan - [x] Tested swagger redirect logic with different `APPLICATION_ROOT` configurations - [x] Verified app icon path generation for default and subdirectory deployments - [x] Confirmed existing functionality remains unchanged for default deployments - [x] Verified security settings (`FAB_API_SWAGGER_UI`, `@has_access`) are respected - [x] Pre-commit hooks pass (formatting, linting, type checking) ## Additional Context This change follows the existing pattern established in `superset/app.py` where `STATIC_ASSETS_PREFIX` is automatically configured for subdirectory deployments. The swagger endpoint follows the same Flask-AppBuilder patterns used throughout Superset. 🤖 Generated with [Claude Code](https://claude.ai/code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org