@midwayjs/http-proxy 3.5.2 → 3.6.0
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/configuration.js +4 -5
- package/dist/interface.d.ts +1 -0
- package/dist/middleware.js +7 -5
- package/package.json +9 -10
package/dist/configuration.js
CHANGED
|
@@ -10,9 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.HttpProxyConfiguration = void 0;
|
|
13
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
14
|
-
const DefaultConfig = require("./config/config.default");
|
|
15
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
+
const DefaultConfig = require("./config/config.default");
|
|
16
15
|
const middleware_1 = require("./middleware");
|
|
17
16
|
let HttpProxyConfiguration = class HttpProxyConfiguration {
|
|
18
17
|
async onReady() {
|
|
@@ -26,15 +25,15 @@ let HttpProxyConfiguration = class HttpProxyConfiguration {
|
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
27
|
__decorate([
|
|
29
|
-
(0,
|
|
28
|
+
(0, core_1.Inject)(),
|
|
30
29
|
__metadata("design:type", core_1.MidwayApplicationManager)
|
|
31
30
|
], HttpProxyConfiguration.prototype, "applicationManager", void 0);
|
|
32
31
|
__decorate([
|
|
33
|
-
(0,
|
|
32
|
+
(0, core_1.Config)('httpProxy'),
|
|
34
33
|
__metadata("design:type", Object)
|
|
35
34
|
], HttpProxyConfiguration.prototype, "httpProxy", void 0);
|
|
36
35
|
HttpProxyConfiguration = __decorate([
|
|
37
|
-
(0,
|
|
36
|
+
(0, core_1.Configuration)({
|
|
38
37
|
namespace: 'upload',
|
|
39
38
|
importConfigs: [
|
|
40
39
|
{
|
package/dist/interface.d.ts
CHANGED
package/dist/middleware.js
CHANGED
|
@@ -10,11 +10,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.HttpProxyMiddleware = void 0;
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const axios_1 = require("axios");
|
|
15
15
|
let HttpProxyMiddleware = class HttpProxyMiddleware {
|
|
16
16
|
resolve(app) {
|
|
17
|
-
if (app.getFrameworkType() ===
|
|
17
|
+
if (app.getFrameworkType() === core_1.MidwayFrameworkType.WEB_EXPRESS) {
|
|
18
18
|
return async (req, res, next) => {
|
|
19
19
|
return this.execProxy(req, req, res, next, true);
|
|
20
20
|
};
|
|
@@ -47,6 +47,7 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
|
|
|
47
47
|
? `${forwarded}, ${ctx.ip}`
|
|
48
48
|
: ctx.ip;
|
|
49
49
|
reqHeaders['host'] = url.host;
|
|
50
|
+
delete reqHeaders['content-length'];
|
|
50
51
|
const method = req.method.toUpperCase();
|
|
51
52
|
const targetRes = res.res || res;
|
|
52
53
|
const isStream = targetRes.on && targetRes.writable;
|
|
@@ -55,6 +56,7 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
|
|
|
55
56
|
url: url.href,
|
|
56
57
|
headers: reqHeaders,
|
|
57
58
|
responseType: isStream ? 'stream' : 'arrayBuffer',
|
|
59
|
+
timeout: this.httpProxy.proxyTimeout || 0,
|
|
58
60
|
};
|
|
59
61
|
if (method === 'POST' || method === 'PUT') {
|
|
60
62
|
reqOptions.data = (_b = req.body) !== null && _b !== void 0 ? _b : (_c = ctx.request) === null || _c === void 0 ? void 0 : _c.body;
|
|
@@ -137,15 +139,15 @@ let HttpProxyMiddleware = class HttpProxyMiddleware {
|
|
|
137
139
|
}
|
|
138
140
|
};
|
|
139
141
|
__decorate([
|
|
140
|
-
(0,
|
|
142
|
+
(0, core_1.Config)('httpProxy'),
|
|
141
143
|
__metadata("design:type", Object)
|
|
142
144
|
], HttpProxyMiddleware.prototype, "httpProxy", void 0);
|
|
143
145
|
__decorate([
|
|
144
|
-
(0,
|
|
146
|
+
(0, core_1.Logger)(),
|
|
145
147
|
__metadata("design:type", Object)
|
|
146
148
|
], HttpProxyMiddleware.prototype, "logger", void 0);
|
|
147
149
|
HttpProxyMiddleware = __decorate([
|
|
148
|
-
(0,
|
|
150
|
+
(0, core_1.Middleware)()
|
|
149
151
|
], HttpProxyMiddleware);
|
|
150
152
|
exports.HttpProxyMiddleware = HttpProxyMiddleware;
|
|
151
153
|
//# sourceMappingURL=middleware.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/http-proxy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Midway Component for http proxy",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -29,14 +29,13 @@
|
|
|
29
29
|
"axios": "0.27.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@midwayjs/core": "^3.
|
|
33
|
-
"@midwayjs/
|
|
34
|
-
"@midwayjs/
|
|
35
|
-
"@midwayjs/
|
|
36
|
-
"@midwayjs/
|
|
37
|
-
"@midwayjs/
|
|
38
|
-
"@midwayjs/
|
|
39
|
-
"@midwayjs/web": "^3.5.1"
|
|
32
|
+
"@midwayjs/core": "^3.6.0",
|
|
33
|
+
"@midwayjs/express": "^3.6.0",
|
|
34
|
+
"@midwayjs/faas": "^3.6.0",
|
|
35
|
+
"@midwayjs/koa": "^3.6.0",
|
|
36
|
+
"@midwayjs/mock": "^3.6.0",
|
|
37
|
+
"@midwayjs/serverless-app": "^3.6.0",
|
|
38
|
+
"@midwayjs/web": "^3.6.0"
|
|
40
39
|
},
|
|
41
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
|
|
42
41
|
}
|