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

Always returning a 404 after redirection #140

Open
Nickforall opened this issue Sep 12, 2017 · 2 comments
Open

Always returning a 404 after redirection #140

Nickforall opened this issue Sep 12, 2017 · 2 comments

Comments

@Nickforall
Copy link

Whenever I do a redirect, I get a 404 on the page redirected to, even though the url exists when I reload the exact same url. I have checked the http responses of /auth/login and the page redirected to, and they are both valid.

This is what my handler looks like at the moment.

impl AuthenticationController {
    // Route: POST /auth/login
    pub fn login(req: &mut Request) -> IronResult<Response> {
        let url: Url;

        if try!(req.session().get::<middleware::sessions::Login>()).is_some() {
            url = url_for!(req, "index", "status" => "already_loggedin");
        } else {
            if User::authenticate("[email protected]", "password") {
                url = url_for!(req, "index", "status" => "success");
            } else {
                url = url_for!(req, "index", "status" => "failure");
            }
        }

        Ok(Response::with((status::Found, Redirect(url.clone()))))
    }
}
@Nickforall
Copy link
Author

Nickforall commented Sep 12, 2017

I should also mention that the router is mounted using mount:

    let mut router_mount = Mount::new();
    // Mount the static folder on the static route
    router_mount
        .mount("/", routes::all())
        .mount("/static/", Static::new(Path::new("src/static")));

The behaviour doesn't change when I don't use mount, but chain the routes directly.

@Nickforall
Copy link
Author

Small update:

Had some time to debug, whenever a POST redirects, the method property of the request is the following:

Extension("content=Hallo+dit+is+een+test!GET")

Where the part content=Hallo+dit+is+een+test! is the content from the post request that redirected.

When a GET request redirects, this behaviour doesn't appear and the method is as expected. I am not that familiar with Iron, so it would be great if someone can help me find the code that causes this so I can fix it.

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

1 participant