'webpack-dev-server version 4 causing app to infinite refresh
I have recently upgraded my React application to use webpack-dev-server: 4.8.1 however now my application is stuck in an infinite refresh loop when trying to start it in a browser.
The error in my browser console that I can see is around authentication. The authentication error occurs in the point in time when my application doing a redirect to sign in and this is when the infinite refresh starts to happen.
The webpack logs when the refresh occurs shows that there is an invalid request.
webpack 5.72.0 compiled successfully in 1072 ms
<i> [webpack-dev-middleware] wait until bundle finished: /?error_description=invalid_scope&state=RthU8qbnTzthhO7OGWIKMizM9lcuxxwx&error=invalid_request
<i> [webpack-dev-middleware] wait until bundle finished: /?error_description=invalid_scope&state=TnqdsuTRrf0vgy4Q5KanPdrjQxIE0v24&error=invalid_request
My webpack-dev.js file (what's in webpack.common is a bunch of rules and plugins which I have ommitted since I don't believe it is causing the issue):
import path from 'path';
import merge from 'webpack-merge';
import webpack from 'webpack';
import common from './webpack.common';
export default merge(common, {
mode: 'development',
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: {
localIdentName: '[name]_[local]_[hash:base64:3]',
},
}
},
'postcss-loader'
]
}
],
},
output: {
path: path.join(__dirname, '../dist/localdev'),
publicPath: '/',
filename: 'app/[name].js',
},
devServer: {
hot: "only",
open: false,
static : {
directory : path.join(__dirname, "./dist/localdev")
},
devMiddleware: {
publicPath: '/',
},
port: 3000,
historyApiFallback: true,
},
});
Not sure if related but when I had to remove inline: true from the devServer config since it was removed with no replacement in v4 this seems to have started to happen.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
