I have a React app bootstrapped using create-react-app. The application runs in a docker container and has been deployed in a subdomain. Let's say the domain name is http://mycompany.com , then my React app is at http://mycompany.com/users/userid/apps/reactapp .
There is a reverse proxy server that can do URL rewriting, changing the base URL to a subdomain URL. This is what my package.json looks like -
{ "name": "my-app", "version": "0.1.0", "private": true, "dependencies": { "@material-ui/core": "^4.12.4", "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^13.5.0", "@types/classnames": "^2.3.1", "@types/jest": "^27.0.3", "@types/node": "^16.11.47", "@types/react": "^17.0.38", "@types/react-dom": "^17.0.11", "@types/react-icons": "^3.0.0", "@types/react-router-dom": "^5.3.2", "@types/sass": "^1.43.1", "bootstrap": "^5.1.3", "classnames": "^2.3.1", "font-awesome": "^4.7.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-icons": "^4.3.1", "react-router-dom": "^6.3.0", "react-scripts": "5.0.0", "register-service-worker": "^1.7.2", "typescript": "^4.5.4", "web-vitals": "^2.1.2" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] }, "devDependencies": { "css-flatten": "^1.0.1", "react-hot-loader": "^4.13.1", "react-select": "^5.4.0", "sass": "^1.45.2" } }
The problem I am facing is that any JS file changes are not reflected even after I restart the development server using react-scripts start. This is only reflected when I restart the docker container. In the browser, I checked, and the bundle.js file doesn't have the latest changes. I've tried these things -
I can see in the development server logs that file changes are being detected, but these changes are not being served to the browser. Even if I delete a file (so I can see the error log in the development server log), nothing changes in the application even if the browser refreshes.
P粉2872545882024-01-11 15:09:00
You may need to add the following to the server side response headers
"headers": { "/**": { "Cache-Control": "no-store, no-cache" } }
If the problem persists, you can try clearing the browser cache
Related questions: