From b469a7da1316f141c5347389740aea112847a512 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 20 Jun 2026 14:21:12 -0500 Subject: [PATCH] fix: use fetch for DELETE+body to fix file_delete (#649) node:https drops the request body on DELETE requests through some proxy/TLS configurations, causing Gitea to see an empty body and return "file already exists" (routes to CREATE handler). Switch to built-in fetch() for DELETE requests with a body, which handles this correctly. Co-Authored-By: Claude --- src/client.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 70900ed..1d1e535 100644 --- a/src/client.ts +++ b/src/client.ts @@ -52,7 +52,21 @@ export class GiteaClient { } async delete(endpoint: string, body?: unknown): Promise { - return this.request(this.buildUrl(endpoint), 'DELETE', body); + if (body === undefined) { + return this.request(this.buildUrl(endpoint), 'DELETE'); + } + // Use fetch for DELETE+body — node:https drops the body on some + // proxy/TLS configurations, causing the server to see an empty request. + const url = this.buildUrl(endpoint); + const resp = await fetch(url, { + method: 'DELETE', + headers: { ...this.headers }, + body: JSON.stringify(body), + }); + const raw = await resp.text(); + let data: unknown; + try { data = JSON.parse(raw); } catch { data = raw; } + return { status: resp.status, data }; } private buildUrl(endpoint: string, params?: Record): string { -- 2.52.0