@nocobase/devtools 2.3.0-alpha.1 → 3.0.0-alpha.2
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/__tests__/umiConfig.test.js +37 -0
- package/package.json +7 -7
- package/umiConfig.js +26 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/* eslint-env jest */
|
|
11
|
+
|
|
12
|
+
const { getUmiConfig } = require('../umiConfig');
|
|
13
|
+
|
|
14
|
+
describe('getUmiConfig Settings dev proxy', () => {
|
|
15
|
+
const originalEnv = { ...process.env };
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
process.env.APP_PORT = '13001';
|
|
19
|
+
process.env.APP_SETTINGS_PORT = '13004';
|
|
20
|
+
process.env.APP_PUBLIC_PATH = '/nocobase/';
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
process.env = { ...originalEnv };
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('proxies the outer Settings document path without taking over v1 settings', () => {
|
|
28
|
+
const { proxy } = getUmiConfig();
|
|
29
|
+
const rootProxy = proxy['/nocobase/settings{,/**}'];
|
|
30
|
+
|
|
31
|
+
expect(rootProxy).toMatchObject({ target: 'http://127.0.0.1:13004', changeOrigin: true, ws: true });
|
|
32
|
+
expect(rootProxy.pathRewrite).toBeUndefined();
|
|
33
|
+
expect(proxy['/nocobase/apps/*/settings{,/**}']).toBeUndefined();
|
|
34
|
+
expect(proxy['/nocobase/_app/*/settings{,/**}']).toBeUndefined();
|
|
35
|
+
expect(proxy['/nocobase/admin/settings']).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
});
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/devtools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@nocobase/app": "
|
|
9
|
-
"@nocobase/build": "
|
|
10
|
-
"@nocobase/client": "
|
|
11
|
-
"@nocobase/test": "
|
|
12
|
-
"@nocobase/utils": "
|
|
8
|
+
"@nocobase/app": "3.0.0-alpha.2",
|
|
9
|
+
"@nocobase/build": "3.0.0-alpha.2",
|
|
10
|
+
"@nocobase/client": "3.0.0-alpha.2",
|
|
11
|
+
"@nocobase/test": "3.0.0-alpha.2",
|
|
12
|
+
"@nocobase/utils": "3.0.0-alpha.2",
|
|
13
13
|
"@rsbuild/core": "1.7.3",
|
|
14
14
|
"@rsbuild/plugin-less": "^1.6.2",
|
|
15
15
|
"@rsbuild/plugin-node-polyfill": "1.4.4",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
59
59
|
"directory": "packages/core/devtools"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "a3faea21082b30989301de04591ee1b91fd4e6a5"
|
|
62
62
|
}
|
package/umiConfig.js
CHANGED
|
@@ -8,6 +8,7 @@ function getUmiConfig() {
|
|
|
8
8
|
const {
|
|
9
9
|
APP_PORT,
|
|
10
10
|
APP_V2_PORT,
|
|
11
|
+
APP_SETTINGS_PORT,
|
|
11
12
|
API_BASE_URL,
|
|
12
13
|
API_CLIENT_STORAGE_TYPE,
|
|
13
14
|
API_CLIENT_STORAGE_PREFIX,
|
|
@@ -57,6 +58,29 @@ function getUmiConfig() {
|
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
function getSettingsProxy() {
|
|
62
|
+
if (!APP_SETTINGS_PORT) {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const settingsTarget = `http://127.0.0.1:${APP_SETTINGS_PORT}`;
|
|
67
|
+
const settingsPath = `${normalizedAppPublicPath}settings`;
|
|
68
|
+
const createProxyOptions = () => ({
|
|
69
|
+
target: settingsTarget,
|
|
70
|
+
changeOrigin: true,
|
|
71
|
+
ws: true,
|
|
72
|
+
onProxyReq: (proxyReq, req) => {
|
|
73
|
+
if (req?.ip) {
|
|
74
|
+
proxyReq.setHeader('X-Forwarded-For', req.ip);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
[`${settingsPath}{,/**}`]: createProxyOptions(),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
60
84
|
return {
|
|
61
85
|
alias: getPackagePaths().reduce((memo, item) => {
|
|
62
86
|
memo[item[0]] = item[1];
|
|
@@ -100,6 +124,8 @@ function getUmiConfig() {
|
|
|
100
124
|
...getLocalStorageProxy(),
|
|
101
125
|
// v2 shell dev server proxy
|
|
102
126
|
...getClientV2Proxy(),
|
|
127
|
+
// standalone Settings dev server proxy
|
|
128
|
+
...getSettingsProxy(),
|
|
103
129
|
},
|
|
104
130
|
};
|
|
105
131
|
}
|