Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] External assets not reflected in get_asset_url #1527

Closed
karosc opened this issue Jan 15, 2021 · 1 comment
Closed

[BUG] External assets not reflected in get_asset_url #1527

karosc opened this issue Jan 15, 2021 · 1 comment
Labels

Comments

@karosc
Copy link
Contributor

karosc commented Jan 15, 2021

When serving assets from an external path by setting:

serve_locally=False
and
assets_external_path=<url to external asset folder>

css, js, and favicon assets are pulled from the external asset directory when the app is initialized, but if I try to use app.get_asset_url(<asset>) it still pulls the asset from the dash directory rather than the external directory.

Would developers be ammenable to a pull request altering the get_asset_url function to look more like below?

def get_asset_url(self, path):
    if self.config.assets_external_path:
        asset = get_asset_path(
            self.config.assets_external_path,
            path,
            self.config.assets_url_path.lstrip("/"),
        )
    else:
        asset = get_asset_path(
            self.config.requests_pathname_prefix,
           path,
            self.config.assets_url_path.lstrip("/"),
       )

    return asset

For reference get_asset_path is defined in _utils.py as:

def get_asset_path(requests_pathname, asset_path, asset_url_path):

    return "/".join(
        [
            # Only take the first part of the pathname
            requests_pathname.rstrip("/"),
            asset_url_path,
            asset_path,
        ]
    )
@alexcjohnson alexcjohnson changed the title [BUG] [BUG] External assets not reflected in get_asset_url Jan 15, 2021
@alexcjohnson
Copy link
Contributor

Nice find, would you like to make a PR to fix this oversight?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants