DioxusLabs / DioxusLabs/dioxus

Support Local Development When Using base_path

Open
#3,745 0 comments 5 reactions 0 assignees View on GitHub
cli enhancement
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

## 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/.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.