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

trunk serve rejects public_url = "./" #697

Closed
ydirson opened this issue Feb 1, 2024 · 1 comment
Closed

trunk serve rejects public_url = "./" #697

ydirson opened this issue Feb 1, 2024 · 1 comment

Comments

@ydirson
Copy link

ydirson commented Feb 1, 2024

The default public_url = "/" is only suitable when using one server per app, which may not be possible. For example in a project hosted on Github we only get one domain for use with Github Pages.

But we may want to host several version of the app, like in the linked example: public_url = "/" gives an unreasonable constraint, and public_url = "./" gives precisely what is needed, i.e. locating WASM, stylesheets, etc relatively to index.html.

As the linked example shows, this works fine with trunk build, and I am able to generate Github Pages to serve the output of several branches in a single domain, but trunk serve rejects it, apparently due to a check deep inside Axum:

user@perso-dev:leptos-test (master<>)$ RUST_BACKTRACE=1 trunk serve 
2024-02-01T20:41:08.580817Z  INFO 🚀 Starting trunk 0.18.3
2024-02-01T20:41:08.874778Z  INFO 📦 starting build
...
2024-02-01T20:41:12.765645Z  INFO ✅ success
thread 'tokio-runtime-worker' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/trunk-0.18.3/src/serve.rs:278:27:
Paths must start with a `/`
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3f28fe133475ec5faf3413b556bf3cfb0d51336c/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/3f28fe133475ec5faf3413b556bf3cfb0d51336c/library/core/src/panicking.rs:72:14
   2: axum::routing::Router<S,B>::nest_service
   3: trunk::serve::router
   4: trunk::serve::ServeSystem::spawn_server::{{closure}}::{{closure}}
   5: trunk::serve::ServeSystem::run::{{closure}}::{{closure}}
   6: trunk::serve::ServeSystem::run::{{closure}}
   7: tokio::runtime::task::raw::poll
   8: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
   9: tokio::runtime::task::raw::poll
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Aborted
@ctron
Copy link
Collaborator

ctron commented Feb 2, 2024

Yes, and for good reason. This all goes into the discussion of #668, and I think we should continue the discussion there.

In a nutshell, when using serve, --public-url must be an absolute path. When using build, it can be relative.

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

No branches or pull requests

2 participants