From d42901f857fc24a53444e5e6e1ac615717e9d553 Mon Sep 17 00:00:00 2001
From: Robot7769
Date: Wed, 13 Aug 2025 23:47:42 +0200
Subject: [PATCH 1/4] Chore: added EOF
---
ForrestHub-app/app/utils.py | 2 +-
ForrestHub-app/config.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ForrestHub-app/app/utils.py b/ForrestHub-app/app/utils.py
index b3a3060..ef106d5 100644
--- a/ForrestHub-app/app/utils.py
+++ b/ForrestHub-app/app/utils.py
@@ -51,4 +51,4 @@ def setup_logging(root_dir: str, log_folder: str = "ForrestHubLogs"):
console.setFormatter(formatter)
logging.getLogger("").addHandler(console)
- return logging.getLogger(__name__)
\ No newline at end of file
+ return logging.getLogger(__name__)
diff --git a/ForrestHub-app/config.py b/ForrestHub-app/config.py
index 72dcee6..e07d2ea 100644
--- a/ForrestHub-app/config.py
+++ b/ForrestHub-app/config.py
@@ -52,4 +52,4 @@ class Config:
# Disable debug and reloader when using frozen data with live data - production mode
if not FROZEN:
# DEBUG = False
- USE_RELOADER = True
\ No newline at end of file
+ USE_RELOADER = True
From eb4a14495f0f5e4f035293a8b8453298ea938dee Mon Sep 17 00:00:00 2001
From: Robot7769
Date: Wed, 13 Aug 2025 23:50:24 +0200
Subject: [PATCH 2/4] Feat: update Socket.IO connection handling and enforce
HTTPS in Flask app
---
ForrestHub-app/assets/js/forrestHubLib.js | 16 ++++++++++++----
ForrestHub-app/run.py | 12 ++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/ForrestHub-app/assets/js/forrestHubLib.js b/ForrestHub-app/assets/js/forrestHubLib.js
index 91726ce..ef2e1d4 100644
--- a/ForrestHub-app/assets/js/forrestHubLib.js
+++ b/ForrestHub-app/assets/js/forrestHubLib.js
@@ -13,7 +13,7 @@ class ForrestHubLib {
* @param isGame {boolean} - zda se jedná o stránku hry
* @param url {string} - URL serveru pro Socket.io (pokud není zadáno, použije se hostname + port)
*/
- constructor(isGame = true, url = "http://" + window.location.hostname + ":" + window.location.port) {
+ constructor(isGame = true, url) {
if (ForrestHubLib.instance) {
return ForrestHubLib.instance;
}
@@ -29,8 +29,12 @@ class ForrestHubLib {
throw new Error('Socket.io není načteno.');
}
- // Vytvoření socketu
- this.socket = io.connect(url);
+ // Cesta pro Socket.IO (pokud je aplikace pod prefixem, např. /Udavač/, přidej ho)
+ const firstSeg = window.location.pathname.split('/')[1] || '';
+ const socketPath = firstSeg ? `/socket.io/${encodeURIComponent(firstSeg)}` : '/socket.io';
+
+ // Vytvoření socketu bez pevného "http://", prohlížeč použije aktuální origin (vč. https)
+ this.socket = url ? io(url, { path: socketPath }) : io({ path: socketPath });
// Přidání základních event listenerů
this.eventAddListener('connect', () => {
@@ -215,7 +219,11 @@ class ForrestHubLib {
socketSetServerUrl(url) {
this.logDebug(`Měním serverové URL na: ${url}`);
this.socketDisconnect();
- this.socket = io.connect(url);
+
+ const firstSeg = window.location.pathname.split('/')[1] || '';
+ const socketPath = firstSeg ? `/socket.io/${encodeURIComponent(firstSeg)}` : '/socket.io';
+
+ this.socket = url ? io(url, { path: socketPath }) : io({ path: socketPath });
this.logDebug(`Připojeno k novému serveru: ${url}`);
}
diff --git a/ForrestHub-app/run.py b/ForrestHub-app/run.py
index fab192b..cfa480f 100644
--- a/ForrestHub-app/run.py
+++ b/ForrestHub-app/run.py
@@ -6,6 +6,7 @@
from config import Config
from pathlib import Path
from app.utils import is_port_free, find_free_port, setup_logging
+from werkzeug.middleware.proxy_fix import ProxyFix
logger = logging.getLogger(__name__)
@@ -14,6 +15,17 @@
def run_flask(config: object | str, host="0.0.0.0", port=4444):
app = create_app(config)
+
+ # Za reverzní proxy – respektuj X-Forwarded-* (host, proto, port, prefix)
+ app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_host=1, x_proto=1, x_port=1, x_prefix=1)
+
+ # Preferuj https pro generované URL a zabezpeč cookies
+ app.config.update(
+ PREFERRED_URL_SCHEME="https",
+ SESSION_COOKIE_SECURE=True,
+ REMEMBER_COOKIE_SECURE=True,
+ )
+
socketio.run(
app,
host=host,
From 54a5a1629cffa0e258e413de9ec9a0b343b64136 Mon Sep 17 00:00:00 2001
From: Robot7769
Date: Wed, 13 Aug 2025 23:51:58 +0200
Subject: [PATCH 3/4] Fix: handl host QR configuration
---
ForrestHub-app/run.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ForrestHub-app/run.py b/ForrestHub-app/run.py
index cfa480f..3b7ad59 100644
--- a/ForrestHub-app/run.py
+++ b/ForrestHub-app/run.py
@@ -7,7 +7,7 @@
from pathlib import Path
from app.utils import is_port_free, find_free_port, setup_logging
from werkzeug.middleware.proxy_fix import ProxyFix
-
+from app.utils import get_readable_ip
logger = logging.getLogger(__name__)
__version__ = (Path(__file__).parent / "VERSION").read_text().strip()
@@ -57,6 +57,7 @@ def main(port, host, host_qr, version):
if host_qr:
config.HOST_QR = host_qr
+ config.HOST_QR_READABLE = get_readable_ip(config.HOST, config.PORT, config.HOST_QR)
if not is_port_free(config.HOST, config.PORT):
new_port = find_free_port(config.HOST, 4444)
From d88abb7d831f0a169092f6ca1cf98566fcb41517 Mon Sep 17 00:00:00 2001
From: Robot7769
Date: Thu, 14 Aug 2025 00:03:58 +0200
Subject: [PATCH 4/4] Feat: better show QR code for dark reader browser
---
ForrestHub-app/assets/css/global_style.css | 13 +++++++++++++
ForrestHub-app/pages/admin/index.html | 4 +++-
ForrestHub-app/templates/header.html | 4 +++-
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/ForrestHub-app/assets/css/global_style.css b/ForrestHub-app/assets/css/global_style.css
index e69de29..14bb23f 100644
--- a/ForrestHub-app/assets/css/global_style.css
+++ b/ForrestHub-app/assets/css/global_style.css
@@ -0,0 +1,13 @@
+.qrcode-wrapper {
+ display: inline-block;
+ background: #c2c2c2 !important;
+ padding: 0px;
+ height: 286px; /* 256px height + 15px border top + 15px border bottom */
+ border: 15px solid #ffffff !important;
+ border-radius: 10px;
+}
+.qrcode-wrapper canvas,
+.qrcode-wrapper img {
+ display: block;
+ margin-top: -15px;
+}
diff --git a/ForrestHub-app/pages/admin/index.html b/ForrestHub-app/pages/admin/index.html
index cc7440a..d21ce2a 100644
--- a/ForrestHub-app/pages/admin/index.html
+++ b/ForrestHub-app/pages/admin/index.html
@@ -22,7 +22,9 @@ Připojení do hry
Tuto adresu zadejte do prohlížeče na zařízení, které chcete připojit do hry.
-
+
QR kód pro připojení do hry
diff --git a/ForrestHub-app/templates/header.html b/ForrestHub-app/templates/header.html
index c02f38b..7e57106 100644
--- a/ForrestHub-app/templates/header.html
+++ b/ForrestHub-app/templates/header.html
@@ -33,7 +33,9 @@ QR Kód s aktuální adresou