This code could be help you to have a express server 4 which work like a charm with React-Router-Dom, with direct access from Browser. Your url like intra.comet.app/about or intra.comet.app/user/MyLove, go directly to the good react dom component or function
Versions use:
- Express JS:
~4.16.1
- React :
^17.0.2
- React Dom Router :
^5.2.0
We integrate a
-
Express Server create with Express application generator :
express --no-view {yourProject}
after we install react apps ,
-
create a reactApp
yarn create react-app client
-
in "client" folder add react-dom-router
cd client yarn add react-router-dom
-
add Fluent ui Northstar library
yarn add @fluentui/react-northstar
-
in /app.js (Express app) add this lines
app.use('/*', express.static(path.join(__dirname, 'client/build/index.html')))
just before at the end of /app.js
module.exports = app;
-
Prepare your React router
-
Build your client app with
yarn build
in client path -
Enjoy :)