@sap-ux/backend-proxy-middleware 0.6.20 → 0.6.22
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.
- package/dist/base/config.js +2 -1
- package/dist/middleware.js +9 -4
- package/package.json +6 -6
package/dist/base/config.js
CHANGED
|
@@ -31,7 +31,7 @@ exports.getCorporateProxyServer = getCorporateProxyServer;
|
|
|
31
31
|
* @param url - url to be checked
|
|
32
32
|
* @returns true if host is excluded from user's corporate server, false otherwise
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
const isHostExcludedFromProxy = (url) => {
|
|
35
35
|
const noProxyConfig = process.env.no_proxy || process.env.npm_config_noproxy;
|
|
36
36
|
if (noProxyConfig === '*') {
|
|
37
37
|
return true;
|
|
@@ -42,4 +42,5 @@ exports.isHostExcludedFromProxy = (url) => {
|
|
|
42
42
|
return !!noProxyList.find((entry) => entry.startsWith('.') ? host.endsWith(entry) : host.endsWith(`.${entry}`));
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
+
exports.isHostExcludedFromProxy = isHostExcludedFromProxy;
|
|
45
46
|
//# sourceMappingURL=config.js.map
|
package/dist/middleware.js
CHANGED
|
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
16
16
|
const logger_1 = require("@sap-ux/logger");
|
|
17
|
-
const express_1 = require("express");
|
|
18
17
|
const http_proxy_middleware_1 = require("http-proxy-middleware");
|
|
19
18
|
const proxy_1 = require("./base/proxy");
|
|
20
19
|
/**
|
|
@@ -46,20 +45,26 @@ module.exports = ({ options }) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
46
45
|
});
|
|
47
46
|
yield proxy_1.initI18n();
|
|
48
47
|
dotenv_1.default.config();
|
|
49
|
-
const router = express_1.Router();
|
|
50
48
|
const backend = options.configuration.backend;
|
|
51
49
|
const configOptions = (_a = options.configuration.options) !== null && _a !== void 0 ? _a : {};
|
|
52
50
|
configOptions.secure = configOptions.secure !== undefined ? !!configOptions.secure : true;
|
|
53
51
|
try {
|
|
54
52
|
const proxyOptions = yield proxy_1.generateProxyMiddlewareOptions(options.configuration.backend, configOptions, logger);
|
|
55
|
-
|
|
53
|
+
const proxyFn = http_proxy_middleware_1.createProxyMiddleware(proxyOptions);
|
|
56
54
|
logger.info(`Starting backend-proxy-middleware using following configuration:\nbackend: ${JSON.stringify(Object.assign(Object.assign({}, backend), { proxy: formatProxyForLogging(backend.proxy) }))}\noptions: ${JSON.stringify(configOptions)}'`);
|
|
55
|
+
return (req, res, next) => {
|
|
56
|
+
if (req.path.startsWith(backend.path)) {
|
|
57
|
+
proxyFn(req, res, next);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
next();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
57
63
|
}
|
|
58
64
|
catch (e) {
|
|
59
65
|
const message = `Failed to register backend for ${backend.path}. Check configuration in yaml file. \n\t${e}`;
|
|
60
66
|
logger.error(message);
|
|
61
67
|
throw new Error(message);
|
|
62
68
|
}
|
|
63
|
-
return router;
|
|
64
69
|
});
|
|
65
70
|
//# sourceMappingURL=middleware.js.map
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Abackend-proxy-middleware"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.6.
|
|
12
|
+
"version": "0.6.22",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -21,13 +21,12 @@
|
|
|
21
21
|
"!dist/**/*.map"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@sap-ux/axios-extension": "0.9.
|
|
24
|
+
"@sap-ux/axios-extension": "0.9.8",
|
|
25
25
|
"@sap-ux/btp-utils": "0.11.1",
|
|
26
26
|
"@sap-ux/logger": "0.3.0",
|
|
27
|
-
"@sap-ux/store": "0.3.
|
|
27
|
+
"@sap-ux/store": "0.3.4",
|
|
28
28
|
"chalk": "4.1.2",
|
|
29
29
|
"dotenv": "16.0.0",
|
|
30
|
-
"express": "4.17.2",
|
|
31
30
|
"http-proxy-middleware": "2.0.1",
|
|
32
31
|
"https-proxy-agent": "5.0.0",
|
|
33
32
|
"i18next": "20.3.2",
|
|
@@ -35,11 +34,12 @@
|
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@types/express": "4.17.13",
|
|
38
|
-
"@types/prompts": "2.0.14",
|
|
39
37
|
"@types/http-proxy": "^1.17.5",
|
|
38
|
+
"@types/prompts": "2.0.14",
|
|
39
|
+
"@types/supertest": "2.0.12",
|
|
40
|
+
"express": "4.17.2",
|
|
40
41
|
"nock": "13.2.4",
|
|
41
42
|
"supertest": "6.2.2",
|
|
42
|
-
"@types/supertest": "2.0.12",
|
|
43
43
|
"yaml": "2.0.0-10"
|
|
44
44
|
},
|
|
45
45
|
"ui5": {
|