@umijs/server 3.5.30 → 3.5.33
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/lib/Server/Server.js +15 -4
- package/package.json +4 -4
package/lib/Server/Server.js
CHANGED
|
@@ -313,14 +313,25 @@ class Server {
|
|
|
313
313
|
// However, the proxy middleware has no use in this case, and will fail to instantiate.
|
|
314
314
|
|
|
315
315
|
if (proxyConfig.target) {
|
|
316
|
+
const target = typeof proxyConfig.target === 'object' ? url().format(proxyConfig.target) : proxyConfig.target;
|
|
316
317
|
return (0, _httpProxyMiddleware().createProxyMiddleware)(context, _objectSpread(_objectSpread({}, proxyConfig), {}, {
|
|
318
|
+
onProxyReq(proxyReq, req, res) {
|
|
319
|
+
var _proxyConfig$onProxyR;
|
|
320
|
+
|
|
321
|
+
// 修改 host 模拟域名,避免 cors 只允许固定域名时报错
|
|
322
|
+
if (proxyReq.getHeader('origin')) {
|
|
323
|
+
proxyReq.setHeader('origin', target);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
(_proxyConfig$onProxyR = proxyConfig.onProxyReq) === null || _proxyConfig$onProxyR === void 0 ? void 0 : _proxyConfig$onProxyR.call(proxyConfig, proxyReq, req, res);
|
|
327
|
+
},
|
|
328
|
+
|
|
317
329
|
onProxyRes(proxyRes, req, res) {
|
|
318
|
-
var _URL, _proxyConfig$
|
|
330
|
+
var _URL, _proxyConfig$onProxyR2;
|
|
319
331
|
|
|
320
|
-
const target = typeof proxyConfig.target === 'object' ? url().format(proxyConfig.target) : proxyConfig.target;
|
|
321
332
|
const realUrl = ((_URL = new URL(req.url || '', target)) === null || _URL === void 0 ? void 0 : _URL.href) || '';
|
|
322
333
|
proxyRes.headers['x-real-url'] = realUrl;
|
|
323
|
-
(_proxyConfig$
|
|
334
|
+
(_proxyConfig$onProxyR2 = proxyConfig.onProxyRes) === null || _proxyConfig$onProxyR2 === void 0 ? void 0 : _proxyConfig$onProxyR2.call(proxyConfig, proxyRes, req, res);
|
|
324
335
|
}
|
|
325
336
|
|
|
326
337
|
}));
|
|
@@ -438,7 +449,7 @@ class Server {
|
|
|
438
449
|
port
|
|
439
450
|
});
|
|
440
451
|
return new Promise(resolve => {
|
|
441
|
-
_this.listeningApp.listen(foundPort, hostname,
|
|
452
|
+
_this.listeningApp.listen(foundPort, hostname, () => {
|
|
442
453
|
_this.createSocketServer();
|
|
443
454
|
|
|
444
455
|
const ret = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/server",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.33",
|
|
4
4
|
"description": "@umijs/server",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@umijs/core": "3.5.
|
|
28
|
-
"@umijs/deps": "3.5.
|
|
29
|
-
"@umijs/utils": "3.5.
|
|
27
|
+
"@umijs/core": "3.5.33",
|
|
28
|
+
"@umijs/deps": "3.5.33",
|
|
29
|
+
"@umijs/utils": "3.5.33"
|
|
30
30
|
}
|
|
31
31
|
}
|