Basically I want to have a react app, but also this app's API calls have to be routed through a middleware so I need a backend code for this too in same app. I tried doing two ways:
Created express backend with generator. Then added react code in public and added web pack and babel but when I enable routes in express for api, react stops rendering.
Created express backend with generator. Added create-react-app in client folder and added proxy line to the express backend. Now it works and I'm able to calls the Middleware for processing apis. But the thing is both express server and client app run on different ports and I need them in same port.
How do I solve it? Using the Middleware to access services is mandatory, I can't directly just Ajax it from UI. It has to go through backend. And I used kraken generator for the node app.
Technically yes, but it's more hassle than what it's worth. Assuming you already have a fully configured webpack setup for React, you will need the following:
We need to configure Express to serve your React bundle in development. This
app.jswould only be for development purposes only. It should not be used for production.With that said, you'll want something like the following:
For production, this would be simplified to just: