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 @@

Current Status

+ + +
+

+ 🔍 Detected Connection: + {% if is_https_active %} + 🔒 HTTPS ({{ request.scheme.upper() }}) + {% else %} + 🔓 HTTP + {% endif %} +
+ Current host: {{ current_host }} via {{ request.host }} +

+
+ {% if config and config.https_enabled %}
✅ HTTPS ENABLED @@ -29,8 +44,15 @@ {% else %}
⚠️ HTTPS DISABLED -

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 %}
{% endif %}
@@ -195,6 +217,39 @@ text-decoration: underline; } +.status-detection { + background: #f0f7ff; + border-left: 4px solid #0066cc; + padding: 15px; + margin-bottom: 20px; + border-radius: 4px; +} + +.detection-info { + margin: 0; + font-size: 14px; + line-height: 1.6; +} + +.badge { + display: inline-block; + padding: 4px 12px; + border-radius: 4px; + font-size: 12px; + font-weight: 600; + margin-left: 8px; +} + +.badge-success { + background: #d1f0e0; + color: #156b2e; +} + +.badge-warning { + background: #fff3cd; + color: #856404; +} + .status-card { margin-bottom: 30px; border-left: 5px solid #ddd;