44 - [ ` legacyCreateProxyMiddleware ` ] ( #legacycreateproxymiddleware )
55- [ v3 breaking changes] ( #v3-breaking-changes )
66 - [ Removed ` req.url ` patching] ( #removed-requrl-patching )
7+ - [ ` pathRewrite ` (potential behavior change)] ( #pathrewrite-potential-behavior-change )
78 - [ Removed "shorthand" usage] ( #removed-shorthand-usage )
89 - [ Removed ` context ` argument] ( #removed-context-argument )
910 - [ Removed ` logProvider ` and ` logLevel ` options] ( #removed-logprovider-and-loglevel-options )
1314
1415### ` legacyCreateProxyMiddleware `
1516
16- Use the adapter to use v3 without changing too much of your v2 code and configuration .
17+ Use the adapter to use v3 with minimal changes to your v2 implementation .
1718
1819NOTE: ` legacyCreateProxyMiddleware ` will be removed in a future version.
1920
@@ -53,8 +54,39 @@ app.use('/user', proxy({ target: 'http://www.example.org' }));
5354app .use (' /user' , proxy ({ target: ' http://www.example.org/user' }));
5455```
5556
57+ ### ` pathRewrite ` (potential behavior change)
58+
59+ Related to removal of [ ` req.url ` patching] ( #removed-requrl-patching ) .
60+
61+ ` pathRewrite ` now only rewrites the ` path ` after the mount point.
62+
63+ It was common to rewrite the ` basePath ` with the ` pathRewrite ` option:
64+
65+ ``` js
66+ // before
67+ app .use (' /user' , proxy ({
68+ target: ' http://www.example.org'
69+ pathRewrite: { ' ^/user' : ' /secret' }
70+ }));
71+
72+ // after
73+ app .use (' /user' , proxy ({ target: ' http://www.example.org/secret' }));
74+ ```
75+
76+ When proxy is mounted at the root, ` pathRewrite ` should still work as in v2.
77+
78+ ``` js
79+ // not affected
80+ app .use (proxy ({
81+ target: ' http://www.example.org'
82+ pathRewrite: { ' ^/user' : ' /secret' }
83+ }));
84+ ```
85+
5686### Removed "shorthand" usage
5787
88+ Specify the ` target ` option.
89+
5890``` js
5991// before
6092createProxyMiddleware (' http:/www.example.org' );
@@ -65,6 +97,10 @@ createProxyMiddleware({ target: 'http:/www.example.org' });
6597
6698### Removed ` context ` argument
6799
100+ The ` context ` argument has been moved to option: ` pathFilter ` .
101+
102+ Functionality did not change.
103+
68104See [ recipes/pathFilter.md] ( ./recipes/pathFilter.md ) for more information.
69105
70106``` js
@@ -80,14 +116,12 @@ createProxyMiddleware({
80116
81117### Removed ` logProvider ` and ` logLevel ` options
82118
83- Use your external logging library to control the logging level .
119+ Use your external logging library to _ log _ and control the logging _ level _ .
84120
85121Only ` info ` , ` warn ` , ` error ` are used internally for compatibility across different loggers.
86122
87123If you use ` winston ` , make sure to enable interpolation: < https://github.com/winstonjs/winston#string-interpolation >
88124
89- ```` js
90-
91125See [ recipes/logger.md] ( ./recipes/logger.md ) for more information.
92126
93127``` js
@@ -96,7 +130,7 @@ createProxyMiddleware({
96130 target: ' http://www.example.org' ,
97131 logger: console ,
98132});
99- ` ` ` `
133+ ```
100134
101135### Refactored proxy events
102136
0 commit comments