@tuya-sat/micro-dev-proxy 3.2.24 → 3.3.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/appProxy.d.ts +1 -0
- package/dist/appProxy.js +2 -0
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/dist/appProxy.d.ts
CHANGED
package/dist/appProxy.js
CHANGED
|
@@ -68,6 +68,7 @@ class AppProxy {
|
|
|
68
68
|
this.csrfCookie = new token_1.default();
|
|
69
69
|
this.csrfValue = new token_1.default();
|
|
70
70
|
this.target = target;
|
|
71
|
+
this.targetOrigin = new url_1.URL(this.target).origin;
|
|
71
72
|
if (!isMainApp) {
|
|
72
73
|
this.username = username;
|
|
73
74
|
if (password) {
|
|
@@ -201,6 +202,7 @@ class AppProxy {
|
|
|
201
202
|
Object.entries(combineHeaders).forEach(([headerKey, value]) => proxyReq.setHeader(headerKey, value));
|
|
202
203
|
const prevCookie = proxyReq.getHeader('cookie') || '';
|
|
203
204
|
proxyReq.setHeader('cookie', this.getCookie(prevCookie));
|
|
205
|
+
proxyReq.setHeader('origin', this.targetOrigin);
|
|
204
206
|
}
|
|
205
207
|
combinedHeader(prevHeadar) {
|
|
206
208
|
let proccessedHeader = Object.assign({}, prevHeadar);
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function awaiting() {
|
|
|
35
35
|
exports.awaiting = awaiting;
|
|
36
36
|
function createProxy(_a) {
|
|
37
37
|
var { additionHeaders = {} } = _a, restPrevConfig = __rest(_a, ["additionHeaders"]);
|
|
38
|
-
const config = Object.assign({ additionHeaders: Object.assign({ terminalId: os_1.default.hostname() + Date.now() }, additionHeaders), isMainApp: restPrevConfig.isMainApp, loginApi: '/api/login', needProxyApi: ['/api', '/open-api', '/custom-api'], logSign: false, csrf: true }, restPrevConfig);
|
|
38
|
+
const config = Object.assign({ additionHeaders: Object.assign({ terminalId: os_1.default.hostname() + Date.now() }, additionHeaders), isMainApp: restPrevConfig.isMainApp, loginApi: '/api/login', needProxyApi: ['/api', '/open-api', '/custom-api', '/ws'], logSign: false, csrf: true }, restPrevConfig);
|
|
39
39
|
const { needProxyApi } = config, appProxyConfig = __rest(config, ["needProxyApi"]);
|
|
40
40
|
const appProxy = new appProxy_1.default(appProxyConfig);
|
|
41
41
|
return function middleware(app) {
|
|
@@ -47,9 +47,11 @@ function createProxy(_a) {
|
|
|
47
47
|
});
|
|
48
48
|
app.use(needProxyApi, (0, http_proxy_middleware_1.createProxyMiddleware)({
|
|
49
49
|
target: appProxyConfig.target,
|
|
50
|
+
ws: true,
|
|
50
51
|
secure: false,
|
|
51
52
|
changeOrigin: true,
|
|
52
53
|
selfHandleResponse: true,
|
|
54
|
+
onProxyReqWs: appProxy.processReq.bind(appProxy),
|
|
53
55
|
onProxyReq: appProxy.processReq.bind(appProxy),
|
|
54
56
|
onProxyRes: (0, http_proxy_middleware_1.responseInterceptor)(appProxy.processRes.bind(appProxy)),
|
|
55
57
|
}));
|