irodriguez-nebustream opened a new pull request, #33356:
URL: https://github.com/apache/superset/pull/33356

   <!---
   Please write the PR title following the conventions at 
https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   Here's the filled-out pull request description:
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   This PR adds support for `SUPERSET_APP_ROOT` subpath routing to the embedded 
dashboard SDK. When Superset is configured with a subpath (e.g., 
`SUPERSET_APP_ROOT="/charts"`), the embedded dashboard SDK now correctly 
constructs the iframe URL to include this path prefix.
   
   **Problem:**
   When embedding dashboards in applications where Superset is deployed with a 
subpath routing configuration, the SDK would attempt to load the dashboard at 
`/embedded/{id}` instead of the correct path `/charts/embedded/{id}`, resulting 
in 404 errors.
   
   **Solution:**
   - Added an optional `appRootPath` parameter to the `EmbedDashboardParams` 
type
   - Modified the `embedDashboard` function to include the application root 
path in the iframe source URL
   - Normalized the app root path to ensure consistent handling (removing 
trailing slashes)
   
   This change ensures the SDK produces iframe URLs that match Superset's 
routing configuration, eliminating 404 errors and making the embedded dashboard 
feature compatible with subpath deployments.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A - This is an SDK fix that affects routing behavior
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   1. Configure a Superset instance with `SUPERSET_APP_ROOT="/charts"` in the 
config
   2. Use the updated SDK to embed a dashboard:
      ```typescript
      embedDashboard({
        id: "your-dashboard-id",
        supersetDomain: "http://localhost:8088";,
        mountPoint: document.getElementById("dashboard-container"),
        fetchGuestToken: () => fetchGuestTokenFromYourBackend(),
        appRootPath: "/charts"  // Include this new parameter
      });
      ```
   3. Verify that:
      - The iframe loads successfully without 404 errors
      - The iframe source URL is constructed as `/charts/embedded/{id}`
      - The embedded dashboard renders correctly
      - API calls within the iframe (like `/charts/api/v1/me/roles/`) work 
properly
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #XXXX (replace with actual issue number)
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API ✓ (adds optional `appRootPath` parameter 
to SDK)
   - [ ] Removes existing feature or API
   
   **Notes:**
   - This change is backward compatible - existing implementations without 
`appRootPath` will continue to work as before
   - The `appRootPath` parameter is optional and defaults to an empty string to 
maintain backward compatibility
   - Related to Superset's use of `process.env.SUPERSET_APP_ROOT` for subpath 
routing configuration
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to