Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hono/proxy does not preserve response.status #3926

Closed
Tracked by #3919
BarryThePenguin opened this issue Feb 17, 2025 · 1 comment · Fixed by #3927
Closed
Tracked by #3919

hono/proxy does not preserve response.status #3926

BarryThePenguin opened this issue Feb 17, 2025 · 1 comment · Fixed by #3927

Comments

@BarryThePenguin
Copy link
Contributor

BarryThePenguin commented Feb 17, 2025

It doesn't look like the original Response#status is included in the proxy response

I'm unsure if this is an issue with hono, or an issue somewhere else eg; node, undici, or miniflare? It's even an issue when running in Cloudflare Workers

@usualoma
Copy link
Member

Hi, @BarryThePenguin. Thank you for pointing this out!
We need to make the following changes.

diff --git a/src/helper/proxy/index.ts b/src/helper/proxy/index.ts
index 96d19f8c..b692f681 100644
--- a/src/helper/proxy/index.ts
+++ b/src/helper/proxy/index.ts
@@ -129,7 +129,8 @@ export const proxy: ProxyFetch = async (input, proxyInit) => {
   }
 
   return new Response(res.body, {
-    ...res,
+    status: res.status,
+    statusText: res.statusText,
     headers: resHeaders,
   })
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants