From 936a09ec6cf88efe51559535b96aae0ca57f0f34 Mon Sep 17 00:00:00 2001 From: Fleny Date: Sun, 13 Jul 2025 09:02:20 +0200 Subject: [PATCH] fix(rest): Use `.startsWith` on the Content-Type check (#4244) * fix(rest): Use `.startsWith` on the Content-Type check * Fix type error --- packages/rest/src/manager.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/rest/src/manager.ts b/packages/rest/src/manager.ts index 39c211ae4..41710cb51 100644 --- a/packages/rest/src/manager.ts +++ b/packages/rest/src/manager.ts @@ -573,7 +573,8 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage const result = await fetch(`${rest.baseUrl}/v${rest.version}${route}`, rest.createRequestBody(method, options)) if (!result.ok) { - const body = await (result.headers.get('Content-Type') === 'application/json' ? result.json() : result.text()).catch(() => null) + // Sometime the Content-Type may be "application/json; charset=utf-8", for this reason we need to check the start of the header + const body = await (result.headers.get('Content-Type')?.startsWith('application/json') ? result.json() : result.text()).catch(() => null) error.cause = Object.assign(Object.create(baseErrorPrototype), { ok: false,