ipkn / crow

Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)
BSD 3-Clause "New" or "Revised" License
7.46k stars 889 forks source link

How to redirect another url? #346

Open borabaloglu opened 4 years ago

borabaloglu commented 4 years ago

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("/");
});
tunahandag commented 4 years ago

hi, i have the same problem as well.

concernedrat commented 4 years ago

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:/");

evilprince2009 commented 3 years ago

It worked for me

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