Skip to content

Commit

Permalink
frontend web app: Fix direct URL for remote control
Browse files Browse the repository at this point in the history
URL http://frontend:6547/MythFE/ was not being directed to the SPA and
was giving a 404 return code. Now fixed.

Fixes #811
  • Loading branch information
bennettpeter committed Nov 4, 2023
1 parent 26b4a11 commit cddc0ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mythtv/libs/libmythbase/http/mythhttprewrite.cpp
Expand Up @@ -56,7 +56,8 @@ HTTPResponse MythHTTPRewrite::RewriteToSPA(const HTTPRequest2& Request, const QS
LOG(VB_HTTP, LOG_INFO, QString("Rewriting request to web app '%1'").arg(File));
if (!File.isEmpty()
&& (Request->m_path.isEmpty() || Request->m_path == "/"
|| Request->m_path == "/dashboard/" || Request->m_path == "/setupwizard/"))
|| Request->m_path == "/dashboard/" || Request->m_path == "/setupwizard/"
|| Request->m_path == "/MythFE/"))
{
Request->m_fileName = File;
Request->m_status = HTTPOK;
Expand Down
6 changes: 6 additions & 0 deletions mythtv/programs/mythfrontend/mythfrontend.cpp
Expand Up @@ -133,6 +133,7 @@ static inline void fe_sd_notify(const char */*str*/) {};
#include "libmythbase/http/mythhttproot.h"
#include "libmythbase/http/mythhttpinstance.h"
#include "services/mythfrontendservice.h"
#include "libmythbase/http/mythhttprewrite.h"

static MythThemedMenu *g_menu;

Expand Down Expand Up @@ -2212,6 +2213,11 @@ Q_DECL_EXPORT int main(int argc, char **argv)
int ret = 0;
{
MythHTTPInstance::Addservices({{ FRONTEND_SERVICE, &MythHTTPService::Create<MythFrontendService> }});

// Send all unknown requests into the web app. make bookmarks and direct access work.
auto spa_index = [](auto && PH1) { return MythHTTPRewrite::RewriteToSPA(std::forward<decltype(PH1)>(PH1), "mythfrontend.html"); };
MythHTTPInstance::AddErrorPageHandler({ "=404", spa_index });

auto root = [](auto && PH1) { return MythHTTPRoot::RedirectRoot(std::forward<decltype(PH1)>(PH1), "mythfrontend.html"); };
MythHTTPScopedInstance webserver({{ "/", root}});
ret = QCoreApplication::exec();
Expand Down

0 comments on commit cddc0ab

Please sign in to comment.