Re: [PR] kie-issues#2209: CORS Proxy sometimes break with gzip encoded responses [incubator-kie-tools]

2026-01-22 Thread via GitHub


thiagoelg merged PR #3395:
URL: https://github.com/apache/incubator-kie-tools/pull/3395


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] kie-issues#2209: CORS Proxy sometimes break with gzip encoded responses [incubator-kie-tools]

2026-01-22 Thread via GitHub


thiagoelg commented on code in PR #3395:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3395#discussion_r2717477560


##
packages/cors-proxy/src/proxy/ExpressCorsProxy.ts:
##
@@ -60,26 +59,33 @@ export class ExpressCorsProxy implements CorsProxy {
   this.logger.debugEscapeNewLines("Request Method: ", req.method);
   this.logger.debugEscapeNewLines("Request Headers: ", req.headers);
 
-  // Creating the headers for the new request
+  // Build outgoing headers
   const outHeaders: Record = { 
...info?.corsConfig?.customHeaders };
 
   Object.keys(req.headers).forEach((header) => {
 if (!BANNED_PROXY_HEADERS.includes(header) && !outHeaders[header]) {
   if (!info.corsConfig || 
info.corsConfig.allowHeaders.includes(header)) {
-outHeaders[header] = req.headers[header] as string;
+const value = req.headers[header];
+// header value can be string | string[] | undefined
+if (Array.isArray(value)) {
+  outHeaders[header] = value.join(", ");
+} else if (typeof value === "string") {
+  outHeaders[header] = value;
+}
   }
 }
   });
 
-  // TO DO: Figure out why this gzip encoding is broken with insecure tls 
certificates!
-  if 
(req.headers[CorsProxyHeaderKeys.INSECURELY_DISABLE_TLS_CERTIFICATE_VALIDATION] 
=== "true") {
-outHeaders["accept-encoding"] = "identity";
-  }
   // Force uncompressed response if encoding is disabled via header
   if (req.headers[CorsProxyHeaderKeys.DISABLE_ENCODING] === "true") {
 outHeaders["accept-encoding"] = "identity";

Review Comment:
   But if I comment out the `res.removeHeader("content-encoding");` line from 
CORS Proxy, then the request fails with `net::ERR_CONTENT_DECODING_FAILED 200 
(OK)`.
   https://github.com/user-attachments/assets/bc8ae922-2e21-4614-af59-3debd6536294";
 />
   
   
   But I think that makes sense, as `node-fetch` in CORS Proxy is already 
decompressing the response and returning raw data to the browser.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] kie-issues#2209: CORS Proxy sometimes break with gzip encoded responses [incubator-kie-tools]

2026-01-22 Thread via GitHub


thiagoelg commented on code in PR #3395:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3395#discussion_r2717447269


##
packages/cors-proxy/src/proxy/ExpressCorsProxy.ts:
##
@@ -60,26 +59,33 @@ export class ExpressCorsProxy implements CorsProxy {
   this.logger.debugEscapeNewLines("Request Method: ", req.method);
   this.logger.debugEscapeNewLines("Request Headers: ", req.headers);
 
-  // Creating the headers for the new request
+  // Build outgoing headers
   const outHeaders: Record = { 
...info?.corsConfig?.customHeaders };
 
   Object.keys(req.headers).forEach((header) => {
 if (!BANNED_PROXY_HEADERS.includes(header) && !outHeaders[header]) {
   if (!info.corsConfig || 
info.corsConfig.allowHeaders.includes(header)) {
-outHeaders[header] = req.headers[header] as string;
+const value = req.headers[header];
+// header value can be string | string[] | undefined
+if (Array.isArray(value)) {
+  outHeaders[header] = value.join(", ");
+} else if (typeof value === "string") {
+  outHeaders[header] = value;
+}
   }
 }
   });
 
-  // TO DO: Figure out why this gzip encoding is broken with insecure tls 
certificates!
-  if 
(req.headers[CorsProxyHeaderKeys.INSECURELY_DISABLE_TLS_CERTIFICATE_VALIDATION] 
=== "true") {
-outHeaders["accept-encoding"] = "identity";
-  }
   // Force uncompressed response if encoding is disabled via header
   if (req.headers[CorsProxyHeaderKeys.DISABLE_ENCODING] === "true") {
 outHeaders["accept-encoding"] = "identity";

Review Comment:
   Yep, it works fine.
   
   https://github.com/user-attachments/assets/e050d484-6809-4fb3-9fd4-35e05ced8b6a";
 />
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] kie-issues#2209: CORS Proxy sometimes break with gzip encoded responses [incubator-kie-tools]

2026-01-19 Thread via GitHub


fantonangeli commented on code in PR #3395:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3395#discussion_r2706002242


##
packages/cors-proxy/src/proxy/ExpressCorsProxy.ts:
##
@@ -60,26 +59,33 @@ export class ExpressCorsProxy implements CorsProxy {
   this.logger.debugEscapeNewLines("Request Method: ", req.method);
   this.logger.debugEscapeNewLines("Request Headers: ", req.headers);
 
-  // Creating the headers for the new request
+  // Build outgoing headers
   const outHeaders: Record = { 
...info?.corsConfig?.customHeaders };
 
   Object.keys(req.headers).forEach((header) => {
 if (!BANNED_PROXY_HEADERS.includes(header) && !outHeaders[header]) {
   if (!info.corsConfig || 
info.corsConfig.allowHeaders.includes(header)) {
-outHeaders[header] = req.headers[header] as string;
+const value = req.headers[header];
+// header value can be string | string[] | undefined
+if (Array.isArray(value)) {
+  outHeaders[header] = value.join(", ");
+} else if (typeof value === "string") {
+  outHeaders[header] = value;
+}
   }
 }
   });
 
-  // TO DO: Figure out why this gzip encoding is broken with insecure tls 
certificates!
-  if 
(req.headers[CorsProxyHeaderKeys.INSECURELY_DISABLE_TLS_CERTIFICATE_VALIDATION] 
=== "true") {
-outHeaders["accept-encoding"] = "identity";
-  }
   // Force uncompressed response if encoding is disabled via header
   if (req.headers[CorsProxyHeaderKeys.DISABLE_ENCODING] === "true") {
 outHeaders["accept-encoding"] = "identity";

Review Comment:
   You can test using the header:
   ```
   Accept-Encoding: gzip, deflate, br, zstd
   ```
   and if you receive this, you are testing it with brotli:
   
   ```
   content-encoding: br
   ```
   I tried to query this brotli service without the CORS Proxy, with success. 
   Last week it was impossible for me to receive any brotli compressed content, 
receiving `NS_ERROR_INVALID_CONTENT_ENCODING` in the browser. This is why I 
thought it was a temporary issue not related to CORS Proxy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] kie-issues#2209: CORS Proxy sometimes break with gzip encoded responses [incubator-kie-tools]

2026-01-19 Thread via GitHub


thiagoelg commented on code in PR #3395:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3395#discussion_r2705529077


##
packages/cors-proxy/src/proxy/ExpressCorsProxy.ts:
##
@@ -60,26 +59,33 @@ export class ExpressCorsProxy implements CorsProxy {
   this.logger.debugEscapeNewLines("Request Method: ", req.method);
   this.logger.debugEscapeNewLines("Request Headers: ", req.headers);
 
-  // Creating the headers for the new request
+  // Build outgoing headers
   const outHeaders: Record = { 
...info?.corsConfig?.customHeaders };
 
   Object.keys(req.headers).forEach((header) => {
 if (!BANNED_PROXY_HEADERS.includes(header) && !outHeaders[header]) {
   if (!info.corsConfig || 
info.corsConfig.allowHeaders.includes(header)) {
-outHeaders[header] = req.headers[header] as string;
+const value = req.headers[header];
+// header value can be string | string[] | undefined
+if (Array.isArray(value)) {
+  outHeaders[header] = value.join(", ");
+} else if (typeof value === "string") {
+  outHeaders[header] = value;
+}
   }
 }
   });
 
-  // TO DO: Figure out why this gzip encoding is broken with insecure tls 
certificates!
-  if 
(req.headers[CorsProxyHeaderKeys.INSECURELY_DISABLE_TLS_CERTIFICATE_VALIDATION] 
=== "true") {
-outHeaders["accept-encoding"] = "identity";
-  }
   // Force uncompressed response if encoding is disabled via header
   if (req.headers[CorsProxyHeaderKeys.DISABLE_ENCODING] === "true") {
 outHeaders["accept-encoding"] = "identity";

Review Comment:
   I'm not sure how to test that...
   
   I've tried making requests to https://httpbin.org/brotli using the CORS 
Proxy, and it works fine (with or without the `accept-encoding` header).
   I've also tested different encodings available here: 
https://httpbin.org/#/Response_formats



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] kie-issues#2209: CORS Proxy sometimes break with gzip encoded responses [incubator-kie-tools]

2026-01-16 Thread via GitHub


fantonangeli commented on code in PR #3395:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3395#discussion_r2699453481


##
packages/cors-proxy/src/proxy/ExpressCorsProxy.ts:
##
@@ -60,26 +59,33 @@ export class ExpressCorsProxy implements CorsProxy {
   this.logger.debugEscapeNewLines("Request Method: ", req.method);
   this.logger.debugEscapeNewLines("Request Headers: ", req.headers);
 
-  // Creating the headers for the new request
+  // Build outgoing headers
   const outHeaders: Record = { 
...info?.corsConfig?.customHeaders };
 
   Object.keys(req.headers).forEach((header) => {
 if (!BANNED_PROXY_HEADERS.includes(header) && !outHeaders[header]) {
   if (!info.corsConfig || 
info.corsConfig.allowHeaders.includes(header)) {
-outHeaders[header] = req.headers[header] as string;
+const value = req.headers[header];
+// header value can be string | string[] | undefined
+if (Array.isArray(value)) {
+  outHeaders[header] = value.join(", ");
+} else if (typeof value === "string") {
+  outHeaders[header] = value;
+}
   }
 }
   });
 
-  // TO DO: Figure out why this gzip encoding is broken with insecure tls 
certificates!
-  if 
(req.headers[CorsProxyHeaderKeys.INSECURELY_DISABLE_TLS_CERTIFICATE_VALIDATION] 
=== "true") {
-outHeaders["accept-encoding"] = "identity";
-  }
   // Force uncompressed response if encoding is disabled via header
   if (req.headers[CorsProxyHeaderKeys.DISABLE_ENCODING] === "true") {
 outHeaders["accept-encoding"] = "identity";

Review Comment:
   Hi @thiagoelg , I personally had issues with Brotli (`content-encoding: br`) 
compression.
   If you have the possibility,  can you try disabling `br` compression, like 
accepting only `gzip, deflate, zstd`?
   If the issue is with `br` maybe is not a `cors-proxy` issue, but it's 
related to our network, and it's like temporary?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]