From 6b67b25d273e90d4181454eb9e73e60a9b9db8ba Mon Sep 17 00:00:00 2001 From: bruno Date: Fri, 10 Jul 2026 08:22:42 -0400 Subject: [PATCH] fix: CSRF token manquant dans les fetch() POST du board et card detail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - board.html: ajout X-CSRF-Token header sur fetch /api/move et /api/issues - card_detail.html: ajout helper getCsrf() + header sur tous les fetch POST/PATCH - Sans ce fix, drag & drop, création issue, checklists échouent en production --- app/templates/board.html | 12 ++++++++++-- app/templates/card_detail.html | 21 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/templates/board.html b/app/templates/board.html index cc7fc93..52d2246 100644 --- a/app/templates/board.html +++ b/app/templates/board.html @@ -244,7 +244,11 @@ title: '', status: 'todo', create() { if (!this.title.trim()) return; - fetch(`/api/issues/${owner}/${repo}?title=${encodeURIComponent(this.title)}&labels=${this.status}`, { method: 'POST' }) + const csrf = document.cookie.match(/csrf_token=([^;]+)/); + fetch(`/api/issues/${owner}/${repo}?title=${encodeURIComponent(this.title)}&labels=${this.status}`, { + method: 'POST', + headers: { 'X-CSRF-Token': csrf ? csrf[1] : '' } + }) .then(r => r.json()) .then(data => { this.title = ''; @@ -277,7 +281,11 @@ onEnd: function(evt) { const cardId = evt.item.dataset.cardId; const toStatus = evt.to.dataset.status; - fetch(`/api/move?owner=${owner}&repo=${repo}&issue_id=${cardId}&column=${toStatus}`, { method: 'POST' }) + const csrf = document.cookie.match(/csrf_token=([^;]+)/); + fetch(`/api/move?owner=${owner}&repo=${repo}&issue_id=${cardId}&column=${toStatus}`, { + method: 'POST', + headers: { 'X-CSRF-Token': csrf ? csrf[1] : '' } + }) .then(() => { // ponytail: refresh current view after move const activeTab = document.querySelector('.view-tab.active'); diff --git a/app/templates/card_detail.html b/app/templates/card_detail.html index 03293ec..7b237a9 100644 --- a/app/templates/card_detail.html +++ b/app/templates/card_detail.html @@ -99,6 +99,12 @@