webpack-dev-server 4.10.1 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Server.js +25 -27
- package/package.json +1 -1
package/lib/Server.js
CHANGED
|
@@ -2131,32 +2131,6 @@ class Server {
|
|
|
2131
2131
|
});
|
|
2132
2132
|
}
|
|
2133
2133
|
|
|
2134
|
-
{
|
|
2135
|
-
/**
|
|
2136
|
-
*
|
|
2137
|
-
* @param {Request} req
|
|
2138
|
-
* @param {Response} res
|
|
2139
|
-
* @param {NextFunction} next
|
|
2140
|
-
* @returns {void}
|
|
2141
|
-
*
|
|
2142
|
-
*/
|
|
2143
|
-
const optionsRequestResponseMiddleware = (req, res, next) => {
|
|
2144
|
-
if (req.method === "OPTIONS") {
|
|
2145
|
-
res.statusCode = 204;
|
|
2146
|
-
res.setHeader("Content-Length", "0");
|
|
2147
|
-
res.end();
|
|
2148
|
-
return;
|
|
2149
|
-
}
|
|
2150
|
-
next();
|
|
2151
|
-
};
|
|
2152
|
-
|
|
2153
|
-
middlewares.push({
|
|
2154
|
-
name: "options-middleware",
|
|
2155
|
-
path: "*",
|
|
2156
|
-
middleware: optionsRequestResponseMiddleware,
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
2134
|
middlewares.push({
|
|
2161
2135
|
name: "webpack-dev-middleware",
|
|
2162
2136
|
middleware:
|
|
@@ -2411,6 +2385,28 @@ class Server {
|
|
|
2411
2385
|
});
|
|
2412
2386
|
}
|
|
2413
2387
|
|
|
2388
|
+
// Register this middleware always as the last one so that it's only used as a
|
|
2389
|
+
// fallback when no other middleware responses.
|
|
2390
|
+
middlewares.push({
|
|
2391
|
+
name: "options-middleware",
|
|
2392
|
+
path: "*",
|
|
2393
|
+
/**
|
|
2394
|
+
* @param {Request} req
|
|
2395
|
+
* @param {Response} res
|
|
2396
|
+
* @param {NextFunction} next
|
|
2397
|
+
* @returns {void}
|
|
2398
|
+
*/
|
|
2399
|
+
middleware: (req, res, next) => {
|
|
2400
|
+
if (req.method === "OPTIONS") {
|
|
2401
|
+
res.statusCode = 204;
|
|
2402
|
+
res.setHeader("Content-Length", "0");
|
|
2403
|
+
res.end();
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
next();
|
|
2407
|
+
},
|
|
2408
|
+
});
|
|
2409
|
+
|
|
2414
2410
|
if (typeof this.options.setupMiddlewares === "function") {
|
|
2415
2411
|
middlewares = this.options.setupMiddlewares(middlewares, this);
|
|
2416
2412
|
}
|
|
@@ -2987,12 +2983,14 @@ class Server {
|
|
|
2987
2983
|
// an IPv6-address in URLs,
|
|
2988
2984
|
// these are removed from the hostname in url.parse(),
|
|
2989
2985
|
// so we have the pure IPv6-address in hostname.
|
|
2990
|
-
// always allow localhost
|
|
2986
|
+
// For convenience, always allow localhost (hostname === 'localhost')
|
|
2987
|
+
// and its subdomains (hostname.endsWith(".localhost")).
|
|
2991
2988
|
// allow hostname of listening address (hostname === this.options.host)
|
|
2992
2989
|
const isValidHostname =
|
|
2993
2990
|
(hostname !== null && ipaddr.IPv4.isValid(hostname)) ||
|
|
2994
2991
|
(hostname !== null && ipaddr.IPv6.isValid(hostname)) ||
|
|
2995
2992
|
hostname === "localhost" ||
|
|
2993
|
+
(hostname !== null && hostname.endsWith(".localhost")) ||
|
|
2996
2994
|
hostname === this.options.host;
|
|
2997
2995
|
|
|
2998
2996
|
if (isValidHostname) {
|