Fix React dev server issue: Add CRACO configuration to resolve webpack allowedHosts error

This commit is contained in:
Mahmoud M. Abdalla 2025-07-26 21:46:34 +03:00
parent ec8831db5d
commit 8c659dfa20
3 changed files with 20463 additions and 4 deletions

22
frontend/craco.config.js Normal file
View file

@ -0,0 +1,22 @@
module.exports = {
webpack: {
configure: (webpackConfig) => {
// Fix for webpack dev server allowedHosts issue
if (webpackConfig.devServer) {
webpackConfig.devServer.allowedHosts = 'all';
}
return webpackConfig;
},
},
devServer: {
allowedHosts: 'all',
host: 'localhost',
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:5000',
changeOrigin: true,
},
},
},
};

20436
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -13,16 +13,16 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.20.1",
"react-scripts": "5.0.1",
"react-scripts": "^5.0.1",
"react-hot-toast": "^2.4.1",
"react-hook-form": "^7.48.2",
"react-query": "^3.39.3",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
"eslintConfig": {
@ -44,6 +44,7 @@
]
},
"devDependencies": {
"@craco/craco": "^7.1.0",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.32",
"tailwindcss": "^3.3.6"