From 6dc03ad911259f1e7adb44b528dc9d96b9d9ebfb Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 8 Dec 2022 14:27:44 -0600 Subject: [PATCH] webpackDevServer: don't fallback or redirect to index This was causing problems when we typed in a bad URL since instead of getting the expected 404 error, we just got the index page no matter what the request was actually for. --- config/webpackDevServer.config.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/config/webpackDevServer.config.js b/config/webpackDevServer.config.js index 954e48fb..d14d820d 100644 --- a/config/webpackDevServer.config.js +++ b/config/webpackDevServer.config.js @@ -4,7 +4,6 @@ const fs = require('fs'); const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware'); const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware'); const ignoredFiles = require('react-dev-utils/ignoredFiles'); -const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware'); const paths = require('./paths'); const getHttpsConfig = require('./getHttpsConfig'); @@ -96,12 +95,7 @@ module.exports = function (proxy, allowedHost) { https: getHttpsConfig(), host, - historyApiFallback: { - // Paths with dots should still use the history fallback. - // See https://github.com/facebook/create-react-app/issues/387. - disableDotRule: true, - index: paths.publicUrlOrPath, - }, + historyApiFallback: false, // `proxy` is run between `before` and `after` `webpack-dev-server` hooks proxy, onBeforeSetupMiddleware(devServer) { @@ -116,9 +110,6 @@ module.exports = function (proxy, allowedHost) { } }, onAfterSetupMiddleware(devServer) { - // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match - devServer.app.use(redirectServedPath(paths.publicUrlOrPath)); - // This service worker file is effectively a 'no-op' that will reset any // previous service worker registered for the same host:port combination. // We do this in development to avoid hitting the production cache if