From eebb28597286264fd98fe8d0c31b4fa9667c2479 Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:27:23 -0700 Subject: [PATCH] update proxy to support wasm responses --- src/fetchers/fetch.ts | 1 + src/fetchers/standardFetch.ts | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/fetchers/fetch.ts b/src/fetchers/fetch.ts index 50b5434..af31e71 100644 --- a/src/fetchers/fetch.ts +++ b/src/fetchers/fetch.ts @@ -19,6 +19,7 @@ export type FetchHeaders = { export type FetchReply = { text(): Promise; json(): Promise; + arrayBuffer(): Promise; extraHeaders?: FetchHeaders; extraUrl?: string; headers: FetchHeaders; diff --git a/src/fetchers/standardFetch.ts b/src/fetchers/standardFetch.ts index 1c78c55..3bbe553 100644 --- a/src/fetchers/standardFetch.ts +++ b/src/fetchers/standardFetch.ts @@ -41,9 +41,23 @@ export function makeStandardFetcher(f: FetchLike): Fetcher { clearTimeout(timeoutId); let body: any; - const isJson = res.headers.get('content-type')?.includes('application/json'); - if (isJson) body = await res.json(); - else body = await res.text(); + const contentType = res.headers.get('content-type')?.toLowerCase(); + const isJson = contentType?.includes('application/json'); + const isBinary = + contentType?.includes('application/wasm') || + contentType?.includes('application/octet-stream') || + contentType?.includes('binary'); + + // Handle 204 No Content responses - they have no body + if (res.status === 204) { + body = null; + } else if (isJson) { + body = await res.json(); + } else if (isBinary) { + body = await res.arrayBuffer(); + } else { + body = await res.text(); + } return { body,