fix: prevent encoding issues by removing problematic headers in relay responses

This commit is contained in:
MythEclipse
2026-05-07 22:25:39 +07:00
parent 1a0a947674
commit f691476046
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -46,6 +46,9 @@ async function handler(req: Request): Promise<Response> {
}
const headers = filterHeaders(new Headers(req.headers));
// Prevent compressed responses (gzip, br) that cause encoding bugs in relay
headers.delete("accept-encoding");
const fetchOptions = buildRelayRequest(req, targetUrl, headers);
const response = await fetch(targetUrl, fetchOptions);
+3
View File
@@ -90,11 +90,14 @@ export function isAllowedTarget(url: string): boolean {
export function createRelayResponse(response: Response): Response {
const headers = new Headers(response.headers);
// Remove headers that would confuse the browser or were handled by the proxy
headers.delete("content-encoding");
headers.delete("content-length");
headers.delete("transfer-encoding");
headers.delete("connection");
headers.delete("keep-alive");
headers.delete("x-frame-options"); // Allow embedding if needed
headers.delete("content-security-policy");
// Add CORS for browser UI
headers.set("Access-Control-Allow-Origin", "*");