drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.04k stars 1.06k forks source link

forward cant works #2018

Open GigaDevelopper opened 1 month ago

GigaDevelopper commented 1 month ago

I try forward to another side request but it doesnt work? Can everybody help me? FilterProxy.... std::string public_ip = result[0]["public_ip"].as();

    if(public_ip.empty())
        return fccb();

    // change protocol
    std::regex pattern("(ws|wss|http|https)://");
    public_ip = std::regex_replace(public_ip, pattern, "");
    public_ip.insert(0, "https://"/*req->isOnSecureConnection() ? "https://" : "http://"*/);
    req->attributes()->insert("public_ip", public_ip);

    // forward to other parking by public IP
    return drogon::app().forward(req, std::move(fcb), public_ip,10);
    //return fccb();
}
Mis1eader-dev commented 1 month ago

Have you printed public_ip before the forward to check if it is forwarded to the right party?

One more thing to note, in the present time Drogon can't forward WebSockets, see this issue #2006

Another issue in case your URL contains spaces to be forwarded, is you have to manually reset the path to its original form before forwarding, see issue #2013