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
// TODO improve me after drop `bypass` to always generate error when configuration is bad
2150
-
if(!proxyConfig.bypass){
2151
-
util.deprecate(
2152
-
()=>{},
2153
-
`Invalid proxy configuration:\n\n${JSON.stringify(proxyConfig,null,2)}\n\nThe use of proxy object notation as proxy routes has been removed.\nPlease use the 'router' or 'context' options. Read more at https://github.com/chimurai/http-proxy-middleware/tree/v2.0.6#http-proxy-middleware-options`,
2154
-
"DEP_WEBPACK_DEV_SERVER_PROXY_ROUTES_ARGUMENT",
2155
-
)();
2156
-
}
2146
+
returncreateProxyMiddleware({
2147
+
...proxyConfig,
2148
+
pathFilter: /** @type {string} */(context),
2149
+
});
2157
2150
};
2158
2151
2159
2152
/**
@@ -2219,40 +2212,7 @@ class Server {
2219
2212
}
2220
2213
}
2221
2214
2222
-
// - Check if we have a bypass function defined
2223
-
// - In case the bypass function is defined we'll retrieve the
2224
-
// bypassUrl from it otherwise bypassUrl would be null
2225
-
// TODO remove in the next major in favor `context` and `router` options
"Using the 'bypass' option is deprecated. Please use the 'router' or 'context' options. Read more at https://github.com/chimurai/http-proxy-middleware/tree/v2.0.6#http-proxy-middleware-options",
2231
-
"DEP_WEBPACK_DEV_SERVER_PROXY_BYPASS_ARGUMENT",
2232
-
)();
2233
-
}
2234
-
constbypassUrl=isByPassFuncDefined
2235
-
? await/** @type {ByPass} */(proxyConfig.bypass)(
2236
-
req,
2237
-
res,
2238
-
proxyConfig,
2239
-
)
2240
-
: null;
2241
-
2242
-
if(typeofbypassUrl==="boolean"){
2243
-
// skip the proxy
2244
-
res.statusCode=404;
2245
-
req.url="";
2246
-
next();
2247
-
}elseif(typeofbypassUrl==="string"){
2248
-
// byPass to that url
2249
-
req.url=bypassUrl;
2250
-
next();
2251
-
}elseif(proxyMiddleware){
2252
-
returnproxyMiddleware(req,res,next);
2253
-
}else{
2254
-
next();
2255
-
}
2215
+
returnproxyMiddleware(req,res,next);
2256
2216
};
2257
2217
2258
2218
middlewares.push({
@@ -2735,7 +2695,10 @@ class Server {
2735
2695
* @returns {Promise<void>}
2736
2696
*/
2737
2697
asynclogStatus(){
2738
-
const{ cyan, isColorSupported, red }=require("colorette");
Copy file name to clipboardExpand all lines: migration-v6.md
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ This document serves as a migration guide for `webpack-dev-server@6.0.0`.
5
5
## ⚠ Breaking Changes
6
6
7
7
- Minimum supported `Node.js` version is `20.9.0`.
8
+
- Minimum supported `webpack` version is `5.101.0`.
8
9
- Support for **SockJS** in the WebSocket transport has been removed. Now, only **native WebSocket** is supported, or **custom** client and server implementations can be used.
9
10
- The options for passing to the `proxy` have changed. Please refer to the [http-proxy-middleware migration guide](https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md) for details.
10
11
- Remove support for the spdy server type. Use the http2 server type instead; however, since Express does not work correctly with it, a custom server (e.g., Connect or Hono) should be used.
@@ -72,3 +73,46 @@ This document serves as a migration guide for `webpack-dev-server@6.0.0`.
- The bypass function in the proxy configuration was removed. Use the `pathFilter` and `router` for similar functionality. See the example below.
78
+
79
+
v4:
80
+
81
+
```js
82
+
module.exports= {
83
+
// ...
84
+
devServer: {
85
+
proxy: [
86
+
{
87
+
context:"/api",
88
+
bypass(req, res, proxyOptions) {
89
+
if (req.url.startsWith("/api/special")) {
90
+
return"/special.html";
91
+
}
92
+
},
93
+
},
94
+
],
95
+
},
96
+
};
97
+
```
98
+
99
+
v5:
100
+
101
+
```js
102
+
module.exports= {
103
+
// ...
104
+
devServer: {
105
+
proxy: [
106
+
{
107
+
pathFilter:"/api/special",
108
+
router: () =>"http://localhost:3000", // Original Server
109
+
pathRewrite: () =>"/special.html",
110
+
},
111
+
],
112
+
},
113
+
};
114
+
```
115
+
116
+
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.
117
+
118
+
`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