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

Support Local Development When Using base_path #3745

Open
sanity opened this issue Feb 15, 2025 · 0 comments
Open

Support Local Development When Using base_path #3745

sanity opened this issue Feb 15, 2025 · 0 comments
Labels
cli Related to the dioxus-cli program enhancement New feature or request

Comments

@sanity
Copy link

sanity commented Feb 15, 2025

Feature Request

Currently, when specifying a base_path in Dioxus.toml, it is baked into the WASM at compile time, making all asset paths absolute. This creates issues for local development because:

  1. If a base_path is set, serving the app locally (dioxus serve) does not work correctly from localhost, since asset paths are incorrect unless the app is served from its intended subdirectory.
  2. There is no way to specify base_path dynamically (e.g., via an environment variable), meaning developers must modify Dioxus.toml before each build to support different environments.

This problem affects not just cases where the base_path is unknown ahead of time, but any situation where an app is deployed under a subdirectory rather than the root. It seems like a common issue for anyone using Dioxus in such a setup.

Implementation Suggestion

A few possible solutions to address this issue:

  1. Allow base_path to be specified via an environment variable (DIOXUS_BASE_PATH)

    • This would enable different values for development vs. production without modifying Dioxus.toml in build scripts.
  2. Support relative paths for base_path

    • If base_path = "./" or similar could be interpreted relative to the served HTML file rather than the root, that would allow flexible deployments.
  3. Introduce a base_path override for local builds

    • Some fields in Dioxus.toml already support a different value for local builds—this could be extended to base_path, defaulting to / when running dioxus serve.

Would love to hear thoughts on whether this could be supported in the near future as it would avoid an ugly workaround in an app template I'm working on for https://freenet.org/.

@sanity sanity added the enhancement New feature or request label Feb 15, 2025
@ealmloff ealmloff added the cli Related to the dioxus-cli program label Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the dioxus-cli program enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants