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

Issue 097 - Fix https download link showing as http text behind nginx reverse proxy #100

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
18 changes: 17 additions & 1 deletion src/fileshelter/ui/ShareUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,28 @@

namespace UserInterface::ShareUtils
{

static
std::string
getScheme()
{
// Necessary because the scheme in envonment does not pay attention to X-Forwarded_Proto by default
//and we have to use that beause you cannot get the full URL out of wLink as text
const std::string xForwardedProto = wApp->environment().headerValue("X-Forwarded-Proto");
if (!xForwardedProto.empty())
{
return xForwardedProto; // will be 'http' or 'https'
}

// Fallback if header is not set
return wApp->environment().urlScheme();
}

static
std::string
computeURL(const std::string& internalPath)
{
return wApp->environment().urlScheme() + "://" + wApp->environment().hostName() + (wApp->environment().deploymentPath() == "/" ? "" : wApp->environment().deploymentPath()) + internalPath;
return getScheme() + "://" + wApp->environment().hostName() + (wApp->environment().deploymentPath() == "/" ? "" : wApp->environment().deploymentPath()) + internalPath;
}

std::unique_ptr<Wt::WAnchor>
Expand Down