@requestly/requestly-proxy 1.1.12 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -31,9 +31,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
38
|
const axios = require("axios");
|
|
36
39
|
const parser = require("ua-parser-js");
|
|
40
|
+
const fs_1 = __importDefault(require("fs"));
|
|
37
41
|
const Sentry = __importStar(require("@sentry/browser"));
|
|
38
42
|
const handleMixedResponse = (ctx, destinationUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
43
|
var _a, _b, _c;
|
|
@@ -73,6 +77,34 @@ const handleMixedResponse = (ctx, destinationUrl) => __awaiter(void 0, void 0, v
|
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
}
|
|
80
|
+
if (destinationUrl === null || destinationUrl === void 0 ? void 0 : destinationUrl.startsWith("file://")) {
|
|
81
|
+
const path = destinationUrl.slice(7);
|
|
82
|
+
try {
|
|
83
|
+
// utf-8 is common assumption, but this introduces edge cases
|
|
84
|
+
const data = fs_1.default.readFileSync(path, "utf-8");
|
|
85
|
+
return {
|
|
86
|
+
status: true,
|
|
87
|
+
response_data: {
|
|
88
|
+
headers: { "Cache-Control": "no-cache" },
|
|
89
|
+
status_code: 200,
|
|
90
|
+
body: data,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
Sentry.captureException(err);
|
|
96
|
+
// log for live debugging
|
|
97
|
+
console.log("error in openning local file", err);
|
|
98
|
+
return {
|
|
99
|
+
status: true,
|
|
100
|
+
response_data: {
|
|
101
|
+
headers: { "Cache-Control": "no-cache" },
|
|
102
|
+
status_code: 502,
|
|
103
|
+
body: err === null || err === void 0 ? void 0 : err.message,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
76
108
|
return { status: false };
|
|
77
109
|
});
|
|
78
110
|
exports.default = handleMixedResponse;
|
package/dist/components/proxy-middleware/rule_action_processor/processors/redirect_processor.js
CHANGED
|
@@ -17,7 +17,6 @@ const proxy_ctx_helper_1 = require("../../helpers/proxy_ctx_helper");
|
|
|
17
17
|
const modified_requests_pool_1 = __importDefault(require("../modified_requests_pool"));
|
|
18
18
|
const handle_mixed_response_1 = __importDefault(require("../handle_mixed_response"));
|
|
19
19
|
const utils_1 = require("../utils");
|
|
20
|
-
const { URL } = require("url");
|
|
21
20
|
// adding util to get origin header for handling cors
|
|
22
21
|
const getRequestOrigin = (ctx) => {
|
|
23
22
|
const originalRequestHeaders = ctx.rq.original_request.headers || {};
|