Add site footer and fix proxy-aware viewer URLs.
Build public links from host_url netloc behind reverse proxies so generated viewer URLs do not include the internal upstream port. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+14
-4
@@ -4,6 +4,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from flask import Flask, request
|
from flask import Flask, request
|
||||||
from flask_limiter import Limiter
|
from flask_limiter import Limiter
|
||||||
from flask_limiter.util import get_remote_address
|
from flask_limiter.util import get_remote_address
|
||||||
@@ -34,6 +36,7 @@ def configure_app(flask_app: Flask) -> None:
|
|||||||
x_for=1,
|
x_for=1,
|
||||||
x_proto=1,
|
x_proto=1,
|
||||||
x_host=1,
|
x_host=1,
|
||||||
|
x_port=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
limiter.init_app(flask_app)
|
limiter.init_app(flask_app)
|
||||||
@@ -56,7 +59,14 @@ def configure_app(flask_app: Flask) -> None:
|
|||||||
|
|
||||||
def external_base_url() -> str:
|
def external_base_url() -> str:
|
||||||
"""Build public base URL (respects reverse proxy and PREFERRED_URL_SCHEME)."""
|
"""Build public base URL (respects reverse proxy and PREFERRED_URL_SCHEME)."""
|
||||||
preferred = os.environ.get("PREFERRED_URL_SCHEME", "").strip()
|
host_url = request.host_url.rstrip("/")
|
||||||
if preferred:
|
preferred = os.environ.get("PREFERRED_URL_SCHEME", "").strip().lower()
|
||||||
return f"{preferred}://{request.host}"
|
if not preferred:
|
||||||
return request.host_url.rstrip("/")
|
return host_url
|
||||||
|
|
||||||
|
# Use netloc from host_url (honours ProxyFix / X-Forwarded-Host), not request.host
|
||||||
|
# alone, which can still include the internal upstream port behind a reverse proxy.
|
||||||
|
netloc = urlparse(host_url).netloc
|
||||||
|
if not netloc:
|
||||||
|
netloc = request.host
|
||||||
|
return f"{preferred}://{netloc}"
|
||||||
|
|||||||
@@ -601,6 +601,7 @@ tr:hover td { background: var(--bg-hover); }
|
|||||||
.landing-page {
|
.landing-page {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
@@ -661,6 +662,35 @@ tr:hover td { background: var(--bg-hover); }
|
|||||||
|
|
||||||
.landing-lang { margin-top: 8px; }
|
.landing-lang { margin-top: 8px; }
|
||||||
|
|
||||||
|
.site-footer {
|
||||||
|
text-align: center;
|
||||||
|
padding: 16px 24px 20px;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-footer p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-footer a {
|
||||||
|
color: var(--accent);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-footer a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.landing-page .site-footer {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 520px;
|
||||||
|
background: transparent;
|
||||||
|
border-top: none;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Viewer link banner */
|
/* Viewer link banner */
|
||||||
.viewer-banner {
|
.viewer-banner {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<footer class="site-footer">
|
||||||
|
<p>© 2026 <a href="https://dashy.elpatron.me" target="_blank" rel="noopener noreferrer">KnorrLabs</a> – <a href="https://gitea.elpatron.me/elpatron/Idle-Fantasy-Save-Viewer" target="_blank" rel="noopener noreferrer">Source Code</a></p>
|
||||||
|
</footer>
|
||||||
@@ -73,5 +73,6 @@
|
|||||||
<section class="tab-panel" id="tab-history"></section>
|
<section class="tab-panel" id="tab-history"></section>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
{% include '_footer.html' %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -52,5 +52,6 @@
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</main>
|
</main>
|
||||||
|
{% include '_footer.html' %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user