React Router + Express with Webpack? Cannot get these two to work together

React Router + Express with Webpack? Cannot get these two to work together
0.0 0

#1

I am working on the Voting App back-end project. I have my Express server which has various api endpoints such as /api/createPoll, /api/viewPoll/:poll_id, /api/create_user, as well as serve static files (bundled .js file) containing the UI in the /dist folder.

I have my React components (using React Router) call these API endpoints, but in my view if I go to something like http://localhost:8080/create_user, it says it cannot find that route.

I believe it to be a conflict, since my webserver is technically an ExpressJS server, the routes it uses are the ExpressJS routes, and ignores the React Router routes.

Is there any way I can get React Router UI routes to work well with my ExpressJS server routes? I know I could put my ExpressJS server on Heroku and run the view on something like GitHub pages, but I would prefer to keep them both together on the same platform.

I use webpack to bundle the js, then use gulp-nodemon to load the ExpressJS server.