mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 12:57:47 +00:00
This PR disabled `node-fetch` default compression handling when the response is not streamed. The default behavior in node-fetch is to handle the compression. That's great if you interact with node-fetch as user, but bad if you use it as intermediate proxy server, since it's creating a mismatching related with the body format and length expectations. Instead, we disable compression, get the buffered response and compress it again if needed. --------- Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
11 lines
378 B
JavaScript
11 lines
378 B
JavaScript
const baseUrl = ({ headers }) =>
|
|
`${headers.get('x-forwarded-proto')}://${headers.get('x-forwarded-host')}`;
|
|
|
|
export function GET(request) {
|
|
const { searchParams } = new URL(request.url, baseUrl(request));
|
|
const url = searchParams.get('url');
|
|
const encoding = searchParams.get('encoding');
|
|
const serverUrl = `${url}?encoding=${encoding}`;
|
|
return fetch(serverUrl);
|
|
}
|