From 56b0b160e3406c5c4b74504f73e0886edac5da36 Mon Sep 17 00:00:00 2001
From: "AB from home.homenet"
Date: Tue, 5 Aug 2025 01:50:11 +0300
Subject: [PATCH] Fixed sub links generation
---
vpn/templates/vpn/user_portal.html | 4 ++--
vpn/views.py | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/vpn/templates/vpn/user_portal.html b/vpn/templates/vpn/user_portal.html
index 8f4975a..fabb18e 100644
--- a/vpn/templates/vpn/user_portal.html
+++ b/vpn/templates/vpn/user_portal.html
@@ -482,8 +482,8 @@
One link for all your Xray protocols (VLESS, VMess, Trojan)
- {% url 'xray_subscription' user_links.0.link as xray_url %}{{ request.scheme }}://{{ request.get_host }}{{ xray_url }}
-
+ {% url 'xray_subscription' user_links.0.link as xray_url %}{{ force_scheme|default:request.scheme }}://{{ request.get_host }}{{ xray_url }}
+
{% endif %}
diff --git a/vpn/views.py b/vpn/views.py
index a9c2571..07b440b 100644
--- a/vpn/views.py
+++ b/vpn/views.py
@@ -34,6 +34,9 @@ def userPortal(request, user_hash):
recent_connections = 0
logger.warning(f"No cached statistics found for user {user.username}. Run statistics update task.")
+ # Determine protocol scheme
+ scheme = 'https' if request.is_secure() else 'http'
+
# Group links by server
servers_data = {}
total_links = 0
@@ -157,6 +160,7 @@ def userPortal(request, user_hash):
'recent_connections': recent_connections,
'external_address': EXTERNAL_ADDRESS,
'has_xray_servers': has_xray_servers,
+ 'force_scheme': scheme, # Override request.scheme in template
}
logger.debug(f"Context prepared with keys: {list(context.keys())}")