mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 06:31:09 -05:00
Add CSRF token handling to HTMX requests:
- Configure HTMX to include CSRF token in request headers - Add global HTMX configuration in dashboard.html - Fix CSRF token missing error in moderation actions
This commit is contained in:
@@ -185,6 +185,11 @@
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
// Configure HTMX to include CSRF token in all requests
|
||||
document.body.addEventListener('htmx:configRequest', function(evt) {
|
||||
evt.detail.headers['X-CSRFToken'] = '{{ csrf_token }}';
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:beforeSwap', function(evt) {
|
||||
if (evt.detail.target.id === 'submissions-content') {
|
||||
evt.detail.shouldSwap = true;
|
||||
|
||||
Reference in New Issue
Block a user