@modern-js/main-doc 2.21.0 → 2.21.1
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/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
Modern.js provides out-of-the-box global proxy plugin `@modern-js/plugin-proxy`, which is based on [whistle](https://github.com/avwo/whistle) and can be used to view and modify
|
|
1
|
+
Modern.js provides an out-of-the-box global proxy plugin `@modern-js/plugin-proxy`, which is based on [whistle](https://github.com/avwo/whistle) and can be used to view and modify the requests and responses of HTTP/HTTPS, as well as be used as an HTTP proxy server.
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### Setting Proxy Rules
|
|
4
4
|
|
|
5
|
-
After
|
|
5
|
+
After installing the proxy plugin and configuring the rules, run `pnpm run dev`. Modern.js will automatically enable the proxy server when the development server is started.
|
|
6
6
|
|
|
7
7
|
Specific proxy rules can be set via the [`dev.proxy`](/configure/app/dev/proxy) or the `config/proxy.js` file.
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### Proxy Dashboard
|
|
10
10
|
|
|
11
|
-
After
|
|
11
|
+
After installing the proxy plugin and configuring the proxy rules, run the `pnpm run dev` command:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
App running at:
|
|
@@ -20,8 +20,8 @@ After exec `pnpm run dev` command:
|
|
|
20
20
|
✔ success Proxy Server start on localhost:8899
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
You can see that the proxy server has started successfully in the console.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Access `http://localhost:8899`, and you can set the rules through the dashboard.
|
|
26
26
|
|
|
27
27
|

|
|
@@ -6,7 +6,7 @@ sidebar_position: 5
|
|
|
6
6
|
|
|
7
7
|
## Local Proxy
|
|
8
8
|
|
|
9
|
-
Modern.js provides a way to configure the development proxy in [tools.devServer](/configure/app/tools/dev-server). For example, to proxy the local interface to an online address:
|
|
9
|
+
Modern.js provides a way to configure the development proxy in [`tools.devServer`](/configure/app/tools/dev-server). For example, to proxy the local interface to an online address:
|
|
10
10
|
|
|
11
11
|
```ts title="modern.config.ts"
|
|
12
12
|
import { defineConfig } from '@modern-js/app-tools';
|
|
@@ -25,11 +25,10 @@ export default defineConfig({
|
|
|
25
25
|
});
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
When access `http://localhost:8080/go/api`, the response content will be returned from [http://www.example.com/](http://www.example.com/).
|
|
29
29
|
|
|
30
30
|
:::info
|
|
31
31
|
For more detail, see [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware).
|
|
32
|
-
|
|
33
32
|
:::
|
|
34
33
|
|
|
35
34
|
## Global Proxy
|
|
@@ -40,7 +39,7 @@ import GlobalProxy from "@site-docs-en/components/global-proxy"
|
|
|
40
39
|
|
|
41
40
|
## BFF Proxy
|
|
42
41
|
|
|
43
|
-
By configuring [`bff.proxy`](/configure/app/bff/proxy),
|
|
42
|
+
By configuring [`bff.proxy`](/configure/app/bff/proxy), BFF API requests can be proxied to a specified service. Unlike the other proxy methods above, it can be used in the production environment:
|
|
44
43
|
|
|
45
44
|
```ts title="modern.config.ts"
|
|
46
45
|
export default defineConfig({
|
|
@@ -52,7 +51,7 @@ export default defineConfig({
|
|
|
52
51
|
});
|
|
53
52
|
```
|
|
54
53
|
|
|
55
|
-
For example, when
|
|
54
|
+
For example, when using BFF function in the code, the final request `http://localhost:8080/api/v1/topics` will be automatically proxied to `https://cnodejs.org/api/v1/topics`:
|
|
56
55
|
|
|
57
56
|
```js
|
|
58
57
|
import getTopics from '@api/v1/topics';
|
package/modern.config.ts
CHANGED
|
@@ -130,7 +130,8 @@ export default defineConfig({
|
|
|
130
130
|
],
|
|
131
131
|
},
|
|
132
132
|
route: {
|
|
133
|
-
exclude
|
|
133
|
+
// exclude document fragments from routes
|
|
134
|
+
exclude: ['scripts/**', '**/zh/components/**', '**/en/components/**'],
|
|
134
135
|
},
|
|
135
136
|
builderConfig: {
|
|
136
137
|
output: {
|
package/package.json
CHANGED
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.21.
|
|
18
|
+
"version": "2.21.1",
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@modern-js/builder-doc": "^2.21.
|
|
24
|
+
"@modern-js/builder-doc": "^2.21.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"classnames": "^2",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"fs-extra": "^10",
|
|
34
34
|
"@types/node": "^16",
|
|
35
35
|
"@types/fs-extra": "^9",
|
|
36
|
-
"@modern-js/builder-doc": "2.21.
|
|
37
|
-
"@modern-js/doc-tools": "2.21.
|
|
38
|
-
"@modern-js/doc-plugin-auto-sidebar": "2.21.
|
|
36
|
+
"@modern-js/builder-doc": "2.21.1",
|
|
37
|
+
"@modern-js/doc-tools": "2.21.1",
|
|
38
|
+
"@modern-js/doc-plugin-auto-sidebar": "2.21.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"dev": "modern dev",
|