fix: URL-based room routing — /manwe serves index.html with room pre-filled
ServeDir now falls back to index.html for unknown paths (SPA routing). https://host:port/manwe loads the page with room input pre-filled as "manwe". JS getRoom() already reads the path, now the page actually loads. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -99,10 +99,17 @@ async fn main() -> anyhow::Result<()> {
|
||||
"static"
|
||||
};
|
||||
|
||||
// Serve index.html for any path that isn't /ws/, /metrics, or a static file.
|
||||
// This lets URLs like /manwe load the SPA which reads the room from the path.
|
||||
let static_service = ServeDir::new(static_dir)
|
||||
.fallback(tower_http::services::ServeFile::new(
|
||||
format!("{}/index.html", static_dir),
|
||||
));
|
||||
|
||||
let app = Router::new()
|
||||
.route("/ws/{room}", get(ws_handler))
|
||||
.route("/metrics", get(metrics::metrics_handler))
|
||||
.fallback_service(ServeDir::new(static_dir))
|
||||
.fallback_service(static_service)
|
||||
.with_state(state);
|
||||
|
||||
let listen: SocketAddr = format!("0.0.0.0:{port}").parse()?;
|
||||
|
||||
Reference in New Issue
Block a user