You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 HTTP/HTTPS requests and responses, and can also be used as an HTTP proxy server.
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
-
### Set Proxy Rules
3
+
### Setting Proxy Rules
4
4
5
-
After install the proxy plugin and filling in the rules, execute`pnpm run dev`, Modern.js will automatically enable the proxy server after the development server starts.
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
-
### Use Proxy Dashboard
9
+
### Proxy Dashboard
10
10
11
-
After exec`pnpm run dev` command:
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
-
In the console you can see that the proxy server started successfully.
23
+
You can see that the proxy server has started successfully in the console.
24
24
25
-
Accessing the `http://localhost:8899` and, you can set the rules through the dashboard.
25
+
Access `http://localhost:8899`, and you can set the rules through the dashboard.
Copy file name to clipboardExpand all lines: packages/document/main-doc/docs/en/guides/basic-features/proxy.mdx
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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:
when access `http://localhost:8080/go/api`, the response content is returned from [http://www.example.com/](http://www.example.com/).
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), you can proxy BFF API requests to specified services. Unlike other proxy above, it can also be used in the production environment:
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
exportdefaultdefineConfig({
@@ -52,7 +51,7 @@ export default defineConfig({
52
51
});
53
52
```
54
53
55
-
For example, when a BFF call is used in the code, the final request `http://localhost:8080/api/v1/topics` will auto proxy to `https://cnodejs.org/api/v1/topics`:
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`:
0 commit comments