React + Node Server
We want to be able to use express/hapi/feather/etc using passport for auth and only load our react app after successful login. We also want ES6, live-reloading, and hot-loading for fast development.
A common solution is to run
create-react-app on one port and
node server.js on another. Then you add a
proxy: http://localhost:3000 to the
package.json file and it allows your react app to talk to the express server. When you are ready to deploy to production, you generate static files and only need
node server.js from them on. That works as long as you don't need the express/hapi/koa/server:
- to be the first point of entry
- to provide inital state (you can use componentDidMount() + AJAX to load inital state)
Another solution is to simply have your node server load webpack/babel as needed for development, but default to static files for production.