From 6f8d6655cf04f2b67150b8fe8f9aab65235ac058 Mon Sep 17 00:00:00 2001 From: Corey Jepperson Date: Fri, 13 Jan 2023 13:44:17 -0600 Subject: [PATCH] fix #4395 for global instanceof Response --- packages/remix-node/fetch.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/remix-node/fetch.ts b/packages/remix-node/fetch.ts index ce42c4ed8d3..5ff4e607c4a 100644 --- a/packages/remix-node/fetch.ts +++ b/packages/remix-node/fetch.ts @@ -72,5 +72,15 @@ export const fetch: typeof webFetch = ( ...init, }; - return webFetch(info, init as RequestInit); + return webFetch(info, init as RequestInit) + .then((res) => { + if (res instanceof WebResponse && !(res instanceof NodeResponse)) + return new NodeResponse(res.body, res); + return res; + }) + .catch((res) => { + if (res instanceof WebResponse && !(res instanceof NodeResponse)) + return new NodeResponse(res.body, res); + return res; + }); };