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

try adding frontend path to assets #4460

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions reflex/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Optional

from reflex import constants
from reflex.config import get_config
from reflex.utils.exec import is_backend_only


Expand Down Expand Up @@ -52,6 +53,10 @@ def asset(
The relative URL to the asset.
"""
assets = constants.Dirs.APP_ASSETS
config = get_config()
frontend_path = config.frontend_path
if not frontend_path.endswith("/"):
frontend_path += "/"
backend_only = is_backend_only()

# Local asset handling
Expand All @@ -62,7 +67,7 @@ def asset(
raise ValueError("Subfolder is not supported for local assets.")
if not backend_only and not src_file_local.exists():
raise FileNotFoundError(f"File not found: {src_file_local}")
return f"/{path}"
return f"{frontend_path}{path}"

# Shared asset handling
# Determine the file by which the asset is exposed.
Expand Down Expand Up @@ -92,4 +97,4 @@ def asset(
):
dst_file.symlink_to(src_file_shared)

return f"/{external}/{subfolder}/{path}"
return f"{frontend_path}{external}/{subfolder}/{path}"
Loading