crow icon indicating copy to clipboard operation
crow copied to clipboard

How to redirect another url?

Open borabaloglu opened this issue 5 years ago • 3 comments

Hi guys, I'm trying to redirect logged out users to home page. I wrote the code below but it didn't work. Do you have any ideas about that?

CROW_ROUTE(app, "/logout")([](const crow::request &req, crow::response &res){
    res.redirect("/");
});

borabaloglu avatar Sep 11 '19 11:09 borabaloglu

hi, i have the same problem as well.

tunahandag avatar Sep 13 '19 13:09 tunahandag

the redirect() method just sets the 301 http code and Location header so you need to pass the full URI with host like this res.redirect("http:/");

concernedrat avatar Jan 13 '20 18:01 concernedrat

It worked for me

CROW_ROUTE(app, "/logout")([](const crow::request& req, crow::response& res)
{
    res.redirect("/");
    res.end();
});

evilprince2009 avatar Jun 23 '21 06:06 evilprince2009