Bug Report
Version
tower-http v0.4.4
Platform
All
Description
This function redirects paths that don't end with / and is a directory to the URI with / appended
|
async fn maybe_redirect_or_append_path( |
However it does not take into account where the service could be nested, therefore producing an invalid redirect.
Example directory:
src/
├ main.rs
└ hello/
└ index.html
main.rs:
use axum::{Router, Server};
use tower_http::services::ServeDir;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let serve_dir = ServeDir::new("src");
let router = Router::new().nest_service("/src", serve_dir);
let addr = "0.0.0.0:3000".parse().unwrap();
Server::bind(&addr)
.serve(router.into_make_service())
.await
.unwrap();
}
Going to localhost:3000/src/hello to see the issue
Expected: Redirects to localhost:3000/src/hello/ and returns content at src/hello/index.html
Actual: Redirects to localhost:3000/hello/ and returns Not Found
Bug Report
Version
tower-http v0.4.4Platform
All
Description
This function redirects paths that don't end with
/and is a directory to the URI with/appendedtower-http/tower-http/src/services/fs/serve_dir/open_file.rs
Line 253 in e8eb549
However it does not take into account where the service could be nested, therefore producing an invalid redirect.
Example directory:
main.rs:
Going to
localhost:3000/src/helloto see the issueExpected: Redirects to
localhost:3000/src/hello/and returns content atsrc/hello/index.htmlActual: Redirects to
localhost:3000/hello/and returns Not Found