Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions dist/components/proxy-middleware/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
14 changes: 13 additions & 1 deletion dist/components/proxy-middleware/constants.js
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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);
14 changes: 11 additions & 3 deletions dist/components/proxy-middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading