diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..572c9ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ + + +## [1.3.13](https://github.com/requestly/rq-proxy/compare/v1.3.12...v1.3.13) (2026-01-05) + + +### 🐛 Bug Fixes + +* fix: support 204 in API Client via proxy (#73) ([](https://github.com/requestly/rq-proxy/commit/b5fdd94e5eae1c22c39b7a7f48a61eaf34102938)), closes [#73](https://github.com/requestly/rq-proxy/issues/73) + + +### 🔧 Chores + +* [ENGG-5086] chore: improve content-type logic for body parsing (#74) ([](https://github.com/requestly/rq-proxy/commit/b0e812f4dc8b0fb4e8fa559c447bb56451477205)), closes [#74](https://github.com/requestly/rq-proxy/issues/74) +* chore: added pipelines for release (#75) ([](https://github.com/requestly/rq-proxy/commit/78b2507e9b061b09f8350580707bd374b91a9c97)), closes [#75](https://github.com/requestly/rq-proxy/issues/75) +* chore: update package-lock (#76) ([](https://github.com/requestly/rq-proxy/commit/bdf61520608c6f7106dc0d30c57344db4799a3bb)), closes [#76](https://github.com/requestly/rq-proxy/issues/76) +* chore: update package-lock (#77) ([](https://github.com/requestly/rq-proxy/commit/c31b2a35fe1da1792421f4347e81433f86d16938)), closes [#77](https://github.com/requestly/rq-proxy/issues/77) diff --git a/dist/components/proxy-middleware/constants.d.ts b/dist/components/proxy-middleware/constants.d.ts index c29cd60..98034af 100644 --- a/dist/components/proxy-middleware/constants.d.ts +++ b/dist/components/proxy-middleware/constants.d.ts @@ -9,3 +9,4 @@ export namespace RULE_ACTION { let MODIFY_REQUEST: string; } export const RQ_INTERCEPTED_CONTENT_TYPES: string[]; +export const RQ_INTERCEPTED_CONTENT_TYPES_REGEX: RegExp; diff --git a/dist/components/proxy-middleware/constants.js b/dist/components/proxy-middleware/constants.js index 231c97b..717fd46 100644 --- a/dist/components/proxy-middleware/constants.js +++ b/dist/components/proxy-middleware/constants.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.RQ_INTERCEPTED_CONTENT_TYPES = exports.RULE_ACTION = void 0; +exports.RQ_INTERCEPTED_CONTENT_TYPES_REGEX = exports.RQ_INTERCEPTED_CONTENT_TYPES = exports.RULE_ACTION = void 0; exports.RULE_ACTION = { REDIRECT: "redirect", MODIFY_HEADERS: "modify_headers", @@ -22,3 +22,15 @@ exports.RQ_INTERCEPTED_CONTENT_TYPES = [ "application/json", "application/manifest+json" ]; +exports.RQ_INTERCEPTED_CONTENT_TYPES_REGEX = new RegExp([ + 'text/html', // HTML documents + 'text/plain', // Plain text + 'text/javascript', // JavaScript files + 'application/javascript', // JavaScript (standard MIME) + 'application/x-javascript', // JavaScript (legacy) + 'text/css', // CSS files + 'application/css', // CSS (alternative) + 'application/json', // JSON data + 'application/.+\\+json', // JSON-based media types (including vendor-specific like application/vnd.*) +].join('|'), 'i'); +// console.log(RQ_INTERCEPTED_CONTENT_TYPES_REGEX); diff --git a/dist/components/proxy-middleware/index.js b/dist/components/proxy-middleware/index.js index 2bad9ec..200892f 100644 --- a/dist/components/proxy-middleware/index.js +++ b/dist/components/proxy-middleware/index.js @@ -147,7 +147,7 @@ class ProxyMiddlewareManager { ctx.rq.set_original_request({ body: pre_final_body }); ctx.rq_request_body = pre_final_body; let request_rule_applied = false; - if (parsedBody && constants_1.RQ_INTERCEPTED_CONTENT_TYPES.includes(contentType)) { + if (parsedBody && constants_1.RQ_INTERCEPTED_CONTENT_TYPES_REGEX.test(contentType)) { // Do modifications, if any const { action_result_objs, continue_request } = await rules_middleware.on_request_end(ctx); if (!continue_request) { @@ -189,13 +189,21 @@ class ProxyMiddlewareManager { ctx.rq_response_body = body; ctx.rq_parsed_response_body = parsedBody; ctx.rq_response_status_code = (0, proxy_ctx_helper_1.getResponseStatusCode)(ctx); - if (constants_1.RQ_INTERCEPTED_CONTENT_TYPES.includes(contentType) && parsedBody) { + if (constants_1.RQ_INTERCEPTED_CONTENT_TYPES_REGEX.test(contentType) && parsedBody) { ctx.rq_response_body = parsedBody; ctx.rq.set_original_response({ body: parsedBody }); } const { action_result_objs, continue_request } = await rules_middleware.on_response_end(ctx); const statusCode = ctx.rq_response_status_code || (0, proxy_ctx_helper_1.getResponseStatusCode)(ctx); - ctx.proxyToClientResponse.writeHead(statusCode, http_1.default.STATUS_CODES[statusCode], (0, proxy_ctx_helper_1.getResponseHeaders)(ctx)); + const responseHeaders = (0, proxy_ctx_helper_1.getResponseHeaders)(ctx); + // For 204/304/1xx, remove content headers to prevent errors + if (statusCode === 204 || statusCode === 304 || (statusCode >= 100 && statusCode < 200)) { + delete responseHeaders['content-length']; + delete responseHeaders['Content-Length']; + delete responseHeaders['transfer-encoding']; + delete responseHeaders['Transfer-Encoding']; + } + ctx.proxyToClientResponse.writeHead(statusCode, http_1.default.STATUS_CODES[statusCode], responseHeaders); ctx.proxyToClientResponse.write(ctx.rq_response_body); ctx.rq.set_final_response({ ...(0, proxy_ctx_helper_1.get_response_options)(ctx), diff --git a/dist/components/proxy-middleware/rule_action_processor/processors/modify_response_processor.js b/dist/components/proxy-middleware/rule_action_processor/processors/modify_response_processor.js index 486a780..2c54af6 100644 --- a/dist/components/proxy-middleware/rule_action_processor/processors/modify_response_processor.js +++ b/dist/components/proxy-middleware/rule_action_processor/processors/modify_response_processor.js @@ -63,7 +63,7 @@ const process_modify_response_action = async (action, ctx) => { action.responseType === requestly_core_1.CONSTANTS.RESPONSE_BODY_TYPES.CODE) { const contentTypeHeader = (0, proxy_ctx_helper_1.getResponseContentTypeHeader)(ctx); const contentType = (0, http_helpers_1.getContentType)(contentTypeHeader); - if (constants_1.RQ_INTERCEPTED_CONTENT_TYPES.includes(contentType) || contentType == null) { + if (constants_1.RQ_INTERCEPTED_CONTENT_TYPES_REGEX.test(contentType) || contentType == null) { await modify_response_using_code(action, ctx); delete_breaking_headers(ctx); return (0, utils_1.build_action_processor_response)(action, true); diff --git a/package-lock.json b/package-lock.json index edc5675..8cfdea2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@requestly/requestly-proxy", - "version": "1.3.12", + "version": "1.3.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@requestly/requestly-proxy", - "version": "1.3.12", + "version": "1.3.13", "license": "ISC", "dependencies": { "@requestly/requestly-core": "1.1.1", diff --git a/package.json b/package.json index dd93e92..8b0c4d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@requestly/requestly-proxy", - "version": "1.3.12", + "version": "1.3.13", "description": "Proxy that gives superpowers to all the Requestly clients", "main": "dist/index.js", "types": "dist/index.d.ts",