4
4
- [ ` legacyCreateProxyMiddleware ` ] ( #legacycreateproxymiddleware )
5
5
- [ v3 breaking changes] ( #v3-breaking-changes )
6
6
- [ Removed ` req.url ` patching] ( #removed-requrl-patching )
7
+ - [ ` pathRewrite ` (potential behavior change)] ( #pathrewrite-potential-behavior-change )
7
8
- [ Removed "shorthand" usage] ( #removed-shorthand-usage )
8
9
- [ Removed ` context ` argument] ( #removed-context-argument )
9
10
- [ Removed ` logProvider ` and ` logLevel ` options] ( #removed-logprovider-and-loglevel-options )
@@ -53,8 +54,39 @@ app.use('/user', proxy({ target: 'http://www.example.org' }));
53
54
app .use (' /user' , proxy ({ target: ' http://www.example.org/user' }));
54
55
```
55
56
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
+
56
86
### Removed "shorthand" usage
57
87
88
+ Specify the ` target ` option.
89
+
58
90
``` js
59
91
// before
60
92
createProxyMiddleware (' http:/www.example.org' );
@@ -65,6 +97,10 @@ createProxyMiddleware({ target: 'http:/www.example.org' });
65
97
66
98
### Removed ` context ` argument
67
99
100
+ The ` context ` argument has been moved to option: ` pathFilter ` .
101
+
102
+ Functionality did not change.
103
+
68
104
See [ recipes/pathFilter.md] ( ./recipes/pathFilter.md ) for more information.
69
105
70
106
``` js
@@ -80,14 +116,12 @@ createProxyMiddleware({
80
116
81
117
### Removed ` logProvider ` and ` logLevel ` options
82
118
83
- Use your external logging library to control the logging level .
119
+ Use your external logging library to _ log _ and control the logging _ level _ .
84
120
85
121
Only ` info ` , ` warn ` , ` error ` are used internally for compatibility across different loggers.
86
122
87
123
If you use ` winston ` , make sure to enable interpolation: < https://github.com/winstonjs/winston#string-interpolation >
88
124
89
- ```` js
90
-
91
125
See [ recipes/logger.md] ( ./recipes/logger.md ) for more information.
92
126
93
127
``` js
@@ -96,7 +130,7 @@ createProxyMiddleware({
96
130
target: ' http://www.example.org' ,
97
131
logger: console ,
98
132
});
99
- ` ` ` `
133
+ ```
100
134
101
135
### Refactored proxy events
102
136
0 commit comments