-
Notifications
You must be signed in to change notification settings - Fork 554
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
proxy issues with accept-encoding
(zstd)
#2880
Comments
This link can only get a vaild JSON data by ofetch: // server/api/todos/[slug]/index.ts
export default defineEventHandler(async (event) => {
const slug = getRouterParam(event, "slug");
return await $fetch(
`https://jsonplaceholder.typicode.com/todos/${slug}`
);
}); I think it looks like the target link is blocking the proxy. |
Issues is probably related to proxied encoding headers. using curl (to the same nitro route) also things work. |
I did some debugging, interestingly requests to https://jsonplaceholder.typicode.com/todos are successful while those to https://jsonplaceholder.typicode.com/todos/1 (specific todo) fail. I found out that removing "zstd" in the Accept-Encoding header in the proxy solves this issue, maybe this is helpful. |
Came to the same result same time haha, yes we might need to filter |
accept-encoding
accept-encoding
accept-encoding
(zstd)
Yes it seems like it: nodejs/node#48412 Looks like zstd is already added but not yet released. |
I think safest is to ignore it altogether, similar cases might happen in the future / for other runtimes: unjs/h3#914 thanks for report ❤️ |
Environment
Node v22.1.0
[email protected]
Reproduction
Create new Project, add the following to nitro.config.ts:
routeRules: { "/api/**": { proxy: "https://jsonplaceholder.typicode.com/**" }, },
Describe the bug
I'm not sure what reproduces this, but it seems to be affected by some kind of race condition given the result is not always the same.
When I call http://localhost:3000/api/todos/1 with this setting, I get back
502 Bad Gateway
Bad Gateway
at createError (./node_modules/h3/dist/index.mjs:78:15)
...
or a 200 response with some kind of encoded string/binary data? (see attached screenshot)
![image](https://private-user-images.githubusercontent.com/75441883/386160182-2a552c63-6f40-4a47-90e9-c47d59d08f21.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MDg3NzIsIm5iZiI6MTczOTYwODQ3MiwicGF0aCI6Ii83NTQ0MTg4My8zODYxNjAxODItMmE1NTJjNjMtNmY0MC00YTQ3LTkwZTktYzQ3ZDU5ZDA4ZjIxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDA4MzQzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRiYmE2YzNjZWU3YWI2MmJkZWI3MjA4ZGZmY2Y0NzBmYjM2OTUzN2ZlMjdmZjVhMzhjMGI3YWM5NmZiYjMzMDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.nKE9lvfU6MnbHfPzFZbUzAC2ECmWq-QMtb5PLrX51bs)
In my tests, it seems to be happening ONLY with https requests, http requests work fine.
Additional context
Let me know if you need any more information.
Logs
No response
The text was updated successfully, but these errors were encountered: