Skip to content

Commit 051176c

Browse files
committed
docs: update migration guide to reflect removal of bypass function in proxy configuration
1 parent e61d44b commit 051176c

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

migration-v6.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,36 @@ This document serves as a migration guide for `webpack-dev-server@6.0.0`.
5151
```js
5252
const ip = Server.findIp("v4", true);
5353
```
54+
55+
- The bypass function in the proxy configuration was removed. Use the `pathFilter` and `router` for similar functionality. See the example below.
56+
57+
v4:
58+
59+
```js
60+
proxy: [
61+
{
62+
context: "/api",
63+
bypass: function (req, res, proxyOptions) {
64+
if (req.url.startsWith("/api/special")) {
65+
return "/special.html";
66+
}
67+
},
68+
}
69+
],
70+
```
71+
72+
v5:
73+
74+
```js
75+
proxy: [
76+
{
77+
pathFilter: "/api/special",
78+
router: () => "http://localhost:3000",
79+
pathRewrite: () => "/special.html",
80+
},
81+
],
82+
```
83+
84+
When `bypass` was used and that function returned a boolean, it would automatically result in a `404` request. This can’t be achieved in a similar way now, or, if it returned a string, you can do what was done in the example above.
85+
86+
`bypass` also allowed sending data; this can no longer be done. If you really need to do it, you’d have to create a new route in the proxy that sends the same data, or alternatively create a new route on the main server and, following the example above, send the data you wanted.

0 commit comments

Comments
 (0)