codeant-ai-for-open-source[bot] commented on code in PR #43169:
URL: https://github.com/apache/superset/pull/43169#discussion_r3819080675


##########
superset/app.py:
##########
@@ -242,4 +242,12 @@ def __call__(
             environ["PATH_INFO"] = original_path_info[len(self.app_root) :]
             environ["SCRIPT_NAME"] = self.app_root
             return self.wsgi_app(environ, start_response)
+        if original_path_info == "/static" or 
original_path_info.startswith("/static/"):
+            # Webpack bakes `/static/assets/` into the bundle as its 
publicPath,
+            # so lazily loaded chunks and the assets they reference are always
+            # requested without the app-root prefix. Serve those unprefixed
+            # paths as-is instead of 404ing them; the app root is left off
+            # PATH_INFO and SCRIPT_NAME because the static route is registered
+            # at `/static/...` on the unprefixed app.
+            return self.wsgi_app(environ, start_response)

Review Comment:
   Yes. The middleware change only helps if `/static/...` reaches WSGI; in the 
bundled nginx deployment, nginx currently handles that request first and 
returns 404.
   
   Add a root-level static location alongside the prefixed one, forwarding it 
to Superset without rewriting the path, for example:
   
   ```nginx
   location /static/ {
       proxy_pass http://superset_app/static/;
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
   }
   ```
   
   The exact upstream and shared proxy settings should match the existing 
`${SUPERSET_APP_ROOT}/static` location. Keep the middleware branch as well, 
since non-nginx deployments may route `/static` directly to WSGI. This ensures 
both `/analytics/static/...` and webpack’s unprefixed `/static/...` requests 
work.



-- 
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