Skip to content

Set base_path at runtime? #5136

@SuperKenVery

Description

@SuperKenVery

Feature Request

It would be great if base_path could be set at runtime. People deploy at different sub-paths, and I want to distribute a single binary for all of them.

Implement Suggestion

I suggest adding an argument to router function:

pub fn router(app: fn() -> Element) -> Router {
let cfg = ServeConfig::new();
apply_base_path(
Router::new().serve_dioxus_application(cfg.clone(), app),
app,
cfg,
base_path().map(|s| s.to_string()),
)
}

Like this:

pub fn router(app: fn() -> Element, base_path: Option<String>) -> Router {
    let cfg = ServeConfig::new();
    apply_base_path(
        Router::new().serve_dioxus_application(cfg.clone(), app),
        app,
        cfg,
        base_path.unwrap_or(base_path().map(|s| s.to_string())),
    )
}

But this might be too breaking, and impact many people who doesn't need base_path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions