honor public URL in share links
This commit is contained in:
@@ -25,6 +25,9 @@ db-profile-queries = false;
|
|||||||
# Listen port/addr of the web server
|
# Listen port/addr of the web server
|
||||||
listen-port = 5082;
|
listen-port = 5082;
|
||||||
listen-addr = "0.0.0.0";
|
listen-addr = "0.0.0.0";
|
||||||
|
# Externally visible URL used in generated share links. Leave empty to infer it
|
||||||
|
# from the request. This is normally set when LMS is behind a reverse proxy.
|
||||||
|
public-url = "";
|
||||||
behind-reverse-proxy = false;
|
behind-reverse-proxy = false;
|
||||||
# original-ip-header and trusted-proxies are used only if behind-reverse-proxy is set to true
|
# original-ip-header and trusted-proxies are used only if behind-reverse-proxy is set to true
|
||||||
original-ip-header = "X-Forwarded-For";
|
original-ip-header = "X-Forwarded-For";
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#include "SubsonicResponse.hpp"
|
#include "SubsonicResponse.hpp"
|
||||||
#include "database/objects/MediaLibrary.hpp"
|
#include "database/objects/MediaLibrary.hpp"
|
||||||
#include "database/objects/User.hpp"
|
#include "database/objects/User.hpp"
|
||||||
|
#include "core/IConfig.hpp"
|
||||||
|
#include "core/Service.hpp"
|
||||||
|
|
||||||
namespace lms::api::subsonic
|
namespace lms::api::subsonic
|
||||||
{
|
{
|
||||||
@@ -59,6 +61,12 @@ namespace lms::api::subsonic
|
|||||||
|
|
||||||
std::string RequestContext::getPublicBaseUrl() const
|
std::string RequestContext::getPublicBaseUrl() const
|
||||||
{
|
{
|
||||||
|
std::string publicUrl{ core::Service<core::IConfig>::get()->getString("public-url", "") };
|
||||||
|
while (publicUrl.ends_with('/'))
|
||||||
|
publicUrl.pop_back();
|
||||||
|
if (!publicUrl.empty())
|
||||||
|
return publicUrl;
|
||||||
|
|
||||||
std::string scheme{ _request.headerValue("X-Forwarded-Proto") };
|
std::string scheme{ _request.headerValue("X-Forwarded-Proto") };
|
||||||
if (scheme.empty())
|
if (scheme.empty())
|
||||||
scheme = _request.urlScheme();
|
scheme = _request.urlScheme();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "database/objects/User.hpp"
|
#include "database/objects/User.hpp"
|
||||||
#include "services/podcast/IPodcastService.hpp"
|
#include "services/podcast/IPodcastService.hpp"
|
||||||
#include "core/Service.hpp"
|
#include "core/Service.hpp"
|
||||||
|
#include "core/IConfig.hpp"
|
||||||
|
|
||||||
#include "LmsApplication.hpp"
|
#include "LmsApplication.hpp"
|
||||||
#include "ModalManager.hpp"
|
#include "ModalManager.hpp"
|
||||||
@@ -36,8 +37,15 @@ namespace lms::ui::shareUtils
|
|||||||
LmsApp->getDbSession().create<db::Share>(token, mediaId, user);
|
LmsApp->getDbSession().create<db::Share>(token, mediaId, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& env{ LmsApp->environment() };
|
std::string publicUrl{ core::Service<core::IConfig>::get()->getString("public-url", "") };
|
||||||
const std::string url{ env.urlScheme() + "://" + env.hostName() + "/share/" + token };
|
while (publicUrl.ends_with('/'))
|
||||||
|
publicUrl.pop_back();
|
||||||
|
if (publicUrl.empty())
|
||||||
|
{
|
||||||
|
const auto& env{ LmsApp->environment() };
|
||||||
|
publicUrl = env.urlScheme() + "://" + env.hostName();
|
||||||
|
}
|
||||||
|
const std::string url{ publicUrl + "/share/" + token };
|
||||||
auto modal{ std::make_unique<Wt::WTemplate>(Wt::WString::fromUTF8(R"(
|
auto modal{ std::make_unique<Wt::WTemplate>(Wt::WString::fromUTF8(R"(
|
||||||
<div class="modal fade" tabindex="-1"><div class="modal-dialog"><div class="modal-content">
|
<div class="modal fade" tabindex="-1"><div class="modal-dialog"><div class="modal-content">
|
||||||
<div class="modal-header"><h5 class="modal-title">Share</h5>${close-x class="btn-close" data-bs-dismiss="modal" aria-label="Close"}</div>
|
<div class="modal-header"><h5 class="modal-title">Share</h5>${close-x class="btn-close" data-bs-dismiss="modal" aria-label="Close"}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user