Open huandu opened 1 month ago
Hey @huandu, I'm here to help you with any bugs, questions, or contributions you might have for the repository. Let me know how I can assist you! 😊
The issue arises because the UIManifestProcessor.get_manifest
method does not prepend the STATIC_ASSETS_PREFIX
to the asset paths. The method currently returns paths like "/static/dist/main-js.js"
and "/static/dist/main-css.css"
without the prefix, even when STATIC_ASSETS_PREFIX
is set.
Here's the relevant part of the implementation:
def get_manifest(self) -> dict[str, Callable[[str], list[str]]]:
loaded_chunks = set()
def get_files(bundle: str, asset_type: str = "js") -> list[str]:
files = self.get_manifest_files(bundle, asset_type)
filtered_files = [f for f in files if f not in loaded_chunks]
for f in filtered_files:
loaded_chunks.add(f)
return filtered_files
return {
"js_manifest": lambda bundle: get_files(bundle, "js"),
"css_manifest": lambda bundle: get_files(bundle, "css"),
"assets_prefix": self.app.config["STATIC_ASSETS_PREFIX"]
if self.app
else "",
}
The assets_prefix
is correctly set in the returned dictionary, but it is not applied to the individual asset paths. This discrepancy leads to the URLs of scripts and CSS files missing the configured prefix [1][2].
To fix this, you would need to modify the get_files
function to prepend the STATIC_ASSETS_PREFIX
to each asset path.
To continue talking to Dosu, mention @dosu.
Thanks for opening the PR!
Bug description
Per document on STATIC_ASSETS_PREFIX in config, it should be the prefix of all static assets URLs. However, it's not true for most of JS and CSS files. I believe it's a bug in
superset/extensions/__init__.py
. TheUIManifestProcessor.get_manifest
method should add STATIC_ASSETS_PREFIX to all assets listed in manifest.How to reproduce the bug
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist