Skip to content

Commit

Permalink
chore(webpack): remove proxySetup path, import setupProxy directly
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed May 9, 2024
1 parent 00d0c8a commit 2a92a56
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
1 change: 0 additions & 1 deletion client/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const config = {
appSrc: resolveApp("src"),
appTsConfig: resolveApp("tsconfig.json"),
yarnLockFile: resolveApp("../yarn.lock"),
proxySetup: resolveApp("src/setupProxy.js"),
publicUrlOrPath,
libsPath: resolveApp("../libs"),
moduleFileExtensions,
Expand Down
12 changes: 3 additions & 9 deletions client/config/webpackDevServer.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import fs from "node:fs";
import evalSourceMapMiddleware from "react-dev-utils/evalSourceMapMiddleware.js";
import noopServiceWorkerMiddleware from "react-dev-utils/noopServiceWorkerMiddleware.js";
import ignoredFiles from "react-dev-utils/ignoredFiles.js";
import redirectServedPath from "react-dev-utils/redirectServedPathMiddleware.js";

import paths from "./paths.js";
import getServerConfig from "./getHttpsConfig.js";
import proxySetup from "../src/setupProxy.js";

const host = process.env.HOST || "0.0.0.0";
const sockHost = process.env.WDS_SOCKET_HOST;
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
const sockPort = process.env.WDS_SOCKET_PORT;

const proxySetup = fs.existsSync(paths.proxySetup)
? (await import("file://" + paths.proxySetup)).default
: null;

function config(proxy, allowedHost) {
const disableFirewall =
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === "true";
Expand Down Expand Up @@ -111,10 +107,8 @@ function config(proxy, allowedHost) {
evalSourceMapMiddleware(devServer)
);

if (proxySetup) {
// This registers user provided middleware for proxy reasons
proxySetup(devServer.app);
}
// This registers user provided middleware for proxy reasons
proxySetup(devServer.app);

middlewares.push(
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
Expand Down

0 comments on commit 2a92a56

Please sign in to comment.