Creating a react app using webpack in NX 18 doesn't use historyApiFallback by default
Current Behavior
When creating a new react application in Nx 18 with webpack, the historyApiFallback option for the dev server is not set by default. This causes any refresh on a child page to show Cannot GET /page-2. This used to work with Nx 17 by default.used
Expected Behavior
When creating a new React application using Webpack, you should be able to refresh the page on a child page, and it should show the page.
GitHub Repo
https://github.com/jahumes/test-react-webpack-18
Steps to Reproduce
- Either download the provided repo, or create a new integrated repo using
npx create-nx-workspace - If not using the provided repo, add
@nx/reactand create a new react applicationnx g @nx/react:application react-app --routing - Start the application
nx run react-app:serve - Visit
http://localhost:4200 - Scroll to the bottom and click
Page 2 - Refresh the page
Nx Report
Node : 20.11.1
OS : win32-x64
npm : 10.2.4
nx (global) : 18.0.5
nx : 18.3.4
@nx/js : 18.3.4
@nx/jest : 18.3.4
@nx/linter : 18.3.4
@nx/eslint : 18.3.4
@nx/workspace : 18.3.4
@nx/devkit : 18.3.4
@nx/eslint-plugin : 18.3.4
@nx/react : 18.3.4
@nrwl/tao : 18.3.4
@nx/web : 18.3.4
@nx/webpack : 18.3.4
typescript : 5.4.5
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin
Failure Logs
No response
Package Manager Version
No response
Operating System
- [X] macOS
- [X] Linux
- [X] Windows
- [ ] Other (Please specify)
Additional Information
No response
I can confirm this, is there a solution ?
I setup a new project with react and nx 19.0.3 and had to add historyApiFallback to webpack.config.js to make index.html to be served when the app path is not empty. Please fix.
Any update?