diff --git a/core/middleware.py b/core/middleware.py index 075aea7..bdcd7c6 100644 --- a/core/middleware.py +++ b/core/middleware.py @@ -132,8 +132,17 @@ class SecurityHeadersMiddleware: # Deny framing for all other pages response['X-Frame-Options'] = 'DENY' + # Special handling for static assets (og-image, etc.) + if request.path.startswith('/static/'): + # Allow social media scrapers to access og-image and other static assets + response['X-Frame-Options'] = 'SAMEORIGIN' + response['Cache-Control'] = 'public, max-age=31536000' # 1 year cache + # Remove CSP for static assets to ensure accessibility + if 'Content-Security-Policy' in response: + del response['Content-Security-Policy'] + # Security for critical pages - if request.path.startswith('/admin/') or request.path.startswith('/wallet/'): + elif request.path.startswith('/admin/') or request.path.startswith('/wallet/'): response['X-Frame-Options'] = 'DENY' response['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0' response['Pragma'] = 'no-cache' diff --git a/core/urls.py b/core/urls.py index 3859cfd..179075a 100644 --- a/core/urls.py +++ b/core/urls.py @@ -9,6 +9,7 @@ urlpatterns = [ path('pricing/', views.pricing_view, name='pricing'), path('contact/', views.contact_form_view, name='contact_form'), path('health/', views.health_check_view, name='health_check'), + path('test-og/', views.test_og_view, name='test_og'), # External service wrapper pages path('/', views.external_page_view, name='external_page'), diff --git a/core/views.py b/core/views.py index 6de1006..5bc0aca 100644 --- a/core/views.py +++ b/core/views.py @@ -284,6 +284,11 @@ def health_check_view(request): return JsonResponse(health_data, status=200) +def test_og_view(request): + """Test page for debugging social media Open Graph previews.""" + return render(request, 'test_og.html') + + # Simple external service wrapper configurations EXTERNAL_PAGES = { 'event': { diff --git a/templates/base.html b/templates/base.html index 618d7fc..4196fc7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -17,17 +17,18 @@ - - - + + + + - + diff --git a/templates/test_og.html b/templates/test_og.html new file mode 100644 index 0000000..3f94881 --- /dev/null +++ b/templates/test_og.html @@ -0,0 +1,46 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %}Social Media Test - Quantum Tasks AI{% endblock %} + +{% block og_title %}Social Media Preview Test - Quantum Tasks AI{% endblock %} +{% block og_description %}Testing social media link preview with branded image. This should show the Quantum Tasks AI logo and branding.{% endblock %} + +{% block content %} +
+

Social Media Preview Test

+ +
+

Open Graph Meta Tags Debug

+

OG Image URL: https://www.quantumtaskai.com{% static 'img/og-image.png' %}

+

Current Page URL: https://www.quantumtaskai.com{{ request.get_full_path }}

+

Static URL: {% static 'img/og-image.png' %}

+
+ +
+

Preview Image

+ OG Image Preview +
+ +
+

Testing Instructions

+
    +
  1. Copy this page URL: https://www.quantumtaskai.com/test-og/
  2. +
  3. Paste it in WhatsApp, Discord, Twitter, or LinkedIn
  4. +
  5. Check if the image preview appears
  6. +
  7. Use Facebook Sharing Debugger: https://developers.facebook.com/tools/debug/
  8. +
  9. Use Twitter Card Validator: https://cards-dev.twitter.com/validator
  10. +
+
+ +
+

Troubleshooting

+
    +
  • Social platforms cache previews - may take time to update
  • +
  • Image must be publicly accessible (no authentication required)
  • +
  • Image should be at least 600x315px for optimal display
  • +
  • URL must be publicly accessible (not localhost)
  • +
+
+
+{% endblock %} \ No newline at end of file