diff --git a/app/blueprints/admin.py b/app/blueprints/admin.py old mode 100755 new mode 100644 index 37a7da1..62fe38a --- a/app/blueprints/admin.py +++ b/app/blueprints/admin.py @@ -858,8 +858,22 @@ def https_config(): try: config = HTTPSConfig.get_config() + # Detect actual current HTTPS status + # Check if current connection is HTTPS + is_https_active = request.scheme == 'https' or request.headers.get('X-Forwarded-Proto') == 'https' + current_host = request.host.split(':')[0] # Remove port if present + + # If HTTPS is active but database shows disabled, sync it + if is_https_active and config and not config.https_enabled: + # Update database to reflect actual HTTPS status + config.https_enabled = True + db.session.commit() + log_action('info', f'HTTPS status auto-corrected to enabled (detected from request)') + return render_template('admin/https_config.html', - config=config) + config=config, + is_https_active=is_https_active, + current_host=current_host) except Exception as e: log_action('error', f'Error loading HTTPS config page: {str(e)}') flash('Error loading HTTPS configuration page.', 'danger') diff --git a/app/templates/admin/https_config.html b/app/templates/admin/https_config.html index 1eca987..a3012f1 100644 --- a/app/templates/admin/https_config.html +++ b/app/templates/admin/https_config.html @@ -13,6 +13,21 @@
+ 🔍 Detected Connection:
+ {% if is_https_active %}
+ 🔒 HTTPS ({{ request.scheme.upper() }})
+ {% else %}
+ 🔓 HTTP
+ {% endif %}
+
+ Current host: {{ current_host }} via {{ request.host }}
+
The application is currently running on HTTP only (port 80)
-Enable HTTPS below to secure your application.
+ {% if is_https_active %} ++ ✅ Note: You are currently accessing this page via HTTPS, but the configuration shows as disabled. + This configuration will be automatically updated. Please refresh the page. +
+ {% else %} +The application is currently running on HTTP only (port 80)
+Enable HTTPS below to secure your application.
+ {% endif %}