Feature: Support subpath deployment for Go web UI
Add optional YAMA_WEB_BASE_PATH to mount the whole web UI (index, manifest, static assets, /health, /api/devices, /ws) under a URL prefix such as /remoter behind a reverse proxy. index.html now uses a __BASE_PATH__ placeholder substituted at serve time, the PWA manifest start_url is rooted at the base path, and a mount wrapper redirects the bare prefix to prefix/ and strips it before routing. Include nginx, systemd, and env-file deployment examples for the subpath setup. The shared placeholder is also handled by the MFC server, which serves from the domain root and strips __BASE_PATH__ (to "") so its web remote desktop URLs stay rooted. Co-Authored-By: deepseek-v4-pro
This commit is contained in:
1 parent
32cc7af371
commit
42df128f62
7 files changed
+254
-12
No files matched your search
@@ -35,6 +35,16 @@ static std::string LoadBinaryResourceAsString(int resourceId) {
|
||||
return std::string(static_cast<const char*>(p), size);
|
||||
}
|
||||
|
||||
// Replace all occurrences of `from` with `to` in-place.
|
||||
static void ReplaceAll(std::string& s, const std::string& from, const std::string& to) {
|
||||
if (from.empty()) return;
|
||||
size_t pos = 0;
|
||||
while ((pos = s.find(from, pos)) != std::string::npos) {
|
||||
s.replace(pos, from.length(), to);
|
||||
pos += to.length();
|
||||
}
|
||||
}
|
||||
|
||||
// Challenge-response nonce storage (prevents replay attacks)
|
||||
static std::map<void*, std::string> s_ClientNonces;
|
||||
static std::mutex s_NonceMutex;
|
||||
@@ -231,6 +241,10 @@ void CWebService::ServerThread(int port) {
|
||||
|
||||
// Serve static HTML page and file downloads
|
||||
static std::string cachedHtml = GetWebPageHTML();
|
||||
// server/web/index.html carries a __BASE_PATH__ placeholder for the Go
|
||||
// server's subpath deployment. The MFC server serves from the domain root,
|
||||
// so strip it (→ "") — otherwise the WebSocket/CSS/JS URLs break.
|
||||
ReplaceAll(cachedHtml, "__BASE_PATH__", "");
|
||||
// Log loaded size; zero bytes means the RC BINARY resource is missing or
|
||||
// server/web/index.html was not embedded — check 2015Remote.rc and rebuild.
|
||||
Mprintf("[WebService] index.html loaded: %zu bytes\n", cachedHtml.size());
|
||||
|
||||
Reference in new issue
Block a user