fix: don't send Content-Type on PATCH without body (fixes favorite 400)

This commit is contained in:
clawd
2026-02-18 10:51:19 +00:00
parent 931e2a3c1d
commit b0bd3e533f
3 changed files with 1 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -3,7 +3,7 @@ const BASE_URL = '/api'
export async function apiFetch<T>(path: string, options?: RequestInit): Promise<T> {
const method = options?.method?.toUpperCase() || 'GET';
const headers: Record<string, string> = { ...options?.headers as Record<string, string> };
if (['POST', 'PUT', 'PATCH'].includes(method)) {
if (['POST', 'PUT', 'PATCH'].includes(method) && options?.body) {
headers['Content-Type'] = headers['Content-Type'] || 'application/json';
}
const res = await fetch(`${BASE_URL}${path}`, {