fix: use fetch for DELETE+body to fix file_delete (#649) #20

Merged
jmiller merged 1 commits from fix/649-file-delete-body into main 2026-06-20 20:01:47 +00:00
+15 -1
View File
@@ -52,7 +52,21 @@ export class GiteaClient {
}
async delete(endpoint: string, body?: unknown): Promise<ApiResponse> {
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, string>): string {