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

Index route returns 404 with NormalizePath middleware #318

Closed
mrmykey opened this issue Dec 27, 2022 · 0 comments · Fixed by #347
Closed

Index route returns 404 with NormalizePath middleware #318

mrmykey opened this issue Dec 27, 2022 · 0 comments · Fixed by #347
Labels
C-bug Category: This is a bug.

Comments

@mrmykey
Copy link

mrmykey commented Dec 27, 2022

Bug Report

Versions:
tower-http = "0.3.5"
axum = "0.6.1"

Axum "/" route doesn't work (returns 404) with NormalizePath middleware

#[tokio::main]
async fn main() {
    let app = NormalizePath::trim_trailing_slash(
        Router::new()
            .route("/", get(|| async { "index" }))
            .route("/other", get(|| async { "other" }))
    );

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    axum::Server::bind(&addr).serve(app.into_make_service()).await.expect("Failed to start axum server");
}
@davidpdrsn davidpdrsn added the C-bug Category: This is a bug. label Dec 27, 2022
cassaundra added a commit to cassaundra/tower-http that referenced this issue Mar 24, 2023
Previously, `normalize_path` on `/` would result in an empty string, causing
routers to return 404 on the index route. Fix this by doing nothing if the
resultant string would be empty.

Fixes tower-rs#318.
cassaundra added a commit to cassaundra/tower-http that referenced this issue Mar 24, 2023
Previously, `normalize_path` on `/` would result in an empty string, causing
routers to return 404 on the index route. Fix this by defaulting to `/` if the
resultant path would be empty.

Fixes tower-rs#318.
cassaundra added a commit to cassaundra/tower-http that referenced this issue Apr 1, 2023
Previously, `normalize_path` on `/` would result in an empty string, causing
routers to return 404 on the index route. Fix this by defaulting to `/` if the
resultant path would be empty.

Fixes tower-rs#318.
Nehliin pushed a commit that referenced this issue Apr 11, 2023
Previously, `normalize_path` on `/` would result in an empty string, causing
routers to return 404 on the index route. Fix this by defaulting to `/` if the
resultant path would be empty.

Fixes #318.
gezihuzi pushed a commit to gezihuzi/tower-http that referenced this issue Jul 19, 2023
Previously, `normalize_path` on `/` would result in an empty string, causing
routers to return 404 on the index route. Fix this by defaulting to `/` if the
resultant path would be empty.

Fixes tower-rs#318.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants