Skip to content

Commit 4cd28e8

Browse files
committed
refactor: code
1 parent 9a11b0d commit 4cd28e8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ class Server {
171171
}
172172

173173
setupProxyFeature() {
174+
const { createProxyMiddleware } = require('http-proxy-middleware');
175+
174176
/**
175177
* Assume a proxy configuration specified as:
176178
* proxy: {
@@ -243,8 +245,6 @@ class Server {
243245
// It is possible to use the `bypass` method without a `target`.
244246
// However, the proxy middleware has no use in this case, and will fail to instantiate.
245247
if (proxyConfig.target) {
246-
const { createProxyMiddleware } = require('http-proxy-middleware');
247-
248248
return createProxyMiddleware(context, proxyConfig);
249249
}
250250
};
@@ -341,11 +341,11 @@ class Server {
341341
}
342342

343343
setupStaticServeIndexFeature() {
344+
const serveIndex = require('serve-index');
345+
344346
this.options.static.forEach((staticOption) => {
345347
staticOption.publicPath.forEach((publicPath) => {
346348
if (staticOption.serveIndex) {
347-
const serveIndex = require('serve-index');
348-
349349
this.app.use(publicPath, (req, res, next) => {
350350
// serve-index doesn't fallthrough non-get/head request to next middleware
351351
if (req.method !== 'GET' && req.method !== 'HEAD') {

0 commit comments

Comments
 (0)