From a5545e56871fed8ea6e6e660d15fdc3b906eb7f9 Mon Sep 17 00:00:00 2001 From: Kantin-Petit Date: Tue, 23 Jun 2026 23:49:16 +0200 Subject: [PATCH] fix(web): n'envoie pas content-type json sans corps (DELETE conversation) (v0.36.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fastify rejetait le body vide annoncé application/json (FST_ERR_CTP_EMPTY_JSON_BODY) sur DELETE /api/conversations/:id. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_016w5jRe87MGdd6AMvXQcHNi --- CHANGELOG.md | 6 ++++++ web/src/api.ts | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b593019..3e18983 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ incompatibles. Chaque ligne renvoie à un commit dédié (un artefact = un commi ## [Unreleased] +## [0.36.1] — 2026-06-23 — fix DELETE conversation (body vide) +### Fixed +- Client web `req()` : `content-type: application/json` n'est plus envoyé sur + les requêtes **sans corps** (DELETE) — Fastify rejetait le body vide + (`FST_ERR_CTP_EMPTY_JSON_BODY`). La suppression de conversation fonctionne. + ## [0.36.0] — 2026-06-23 — conversations persistantes (mémoire multi-tour) ### Added - **`conversations/store.ts`** : store SQLite (conversations + messages) avec diff --git a/web/src/api.ts b/web/src/api.ts index cc8df12..e411a1a 100644 --- a/web/src/api.ts +++ b/web/src/api.ts @@ -37,7 +37,10 @@ export class ApiError extends Error { } async function req(path: string, token: string | null, init?: RequestInit): Promise { - const headers: Record = { "content-type": "application/json" }; + const headers: Record = {}; + // content-type seulement s'il y a un corps : sinon Fastify rejette un body + // vide annoncé en application/json (DELETE, etc.). + if (init?.body != null) headers["content-type"] = "application/json"; if (token) headers.authorization = `Bearer ${token}`; const res = await fetch(`/api${path}`, { ...init, headers: { ...headers, ...(init?.headers as Record) } }); if (!res.ok) {