Problem
When using the mdbook serve command with --port 0 and --open options, the opened page is wrong, as the port is 0 instead of the random port attributed by the system.

Steps
mdbook init abc --force
mdbook serve abc --port 0 --open
Possible Solution(s)
The serving_url should contain the bound port instead of the asked port (0)
|
let serving_url = format!("http://{address}"); |
Maybe using something like bind_ephemeral could be used. It would maybe require to move the creation of the warp server in a separate function run before the thread spawn.
|
let thread_handle = std::thread::spawn(move || { |
|
serve(build_dir, sockaddr, reload_tx, &file_404); |
|
}); |
Notes
No response
Version
Problem
When using the
mdbook servecommand with--port 0and--openoptions, the opened page is wrong, as the port is0instead of the random port attributed by the system.Steps
mdbook init abc --forcemdbook serve abc --port 0 --openPossible Solution(s)
The
serving_urlshould contain the bound port instead of the asked port (0)mdBook/src/cmd/serve.rs
Line 92 in 3a8faba
Maybe using something like
bind_ephemeralcould be used. It would maybe require to move the creation of the warp server in a separate function run before the thread spawn.mdBook/src/cmd/serve.rs
Lines 88 to 90 in 3a8faba
Notes
No response
Version