问题
I have gone through different blog articles to find out how a full-fledged application can be modeled and developed with React,Redux (working on front-end) with API end-points communicating with an ExpressJS server.
To my knowledge, we need to have:
a). One
expressJS
application developed with all possible end-points (available for an API access). This application should be running on a port e.g. 7070. This server side application will be communicating with the database.
b). Develop aReact
,Redux
based application for front-end and run this application on a different port e.g. 8080 usingwebpack
,gulp
orgrunt
server.
I am sure this is not the only model. Or, maybe my concept is little weak. But this post will clarify concepts globally to all Frontend+fullstack developers. Please write your recommendations and expert opinions on followings:
Is my defined model right?
Is there a way, or possible to use ExpressJS application to throw a ReactJS application as one-page application (which process and render all defined React routes on client side).
/* a reference example of using root route handler in Express to throw an index file (which includes bundle.js react application), this works okay, but can not handle or render React Routes on client side; and instead if a menu link clicked that sends request to Express but Express application file only had '/' route to handle. */
app.get("/", function(req, res){ res.sendFile(dirname + "index.html"); // but this is not viable })
If point#2 is possible then our application can run on same port right? And our application can also use Express routes as an API end-points. But I'm sure that will not be the recommended way or even possible; unless we do the server side rendering of React (in our server side ExpressJS application).
Deployment
Scenario: React+Redux+Express+DB (mongoDb, Redis, MySql or Postgres etc.) Full Stack application
- Online/Cloud Hosting
Normally we are hosting our application on any 3rd party server (or cloud server). The normal shared hosting does not work unless they have NodeJS server. Most common are: Heroku, AWS, RedHat OpenShift, Nodejitsu, Microsoft Azure, Modulus, Firebase, etc. In this case most of the server side things are easy to setup and headache free. - Local Network (Internal Company/Corporate Server) Hosting
i). Linux Bases server (any version) + SSL installed + Required DB Installation + NodeJS installation + Dedicated IP
ii). Windows Bases Server + SSL installed + Required DB Installation + NodeJS installation + Dedicated IP
Can anyone elaborate more on the internal server hosting setup procedure with all security measures in more details? I really do not know what each step that should be taken would be.
It will also be helpful if any technical person could write about application modeling as well. This will help everyone.
Note: The answers should be short in the question context (not in the question subject line context, which is quite broad). Any reference or links will be good to make answer quite short.
来源:https://stackoverflow.com/questions/41506971/reactjs-expressjs-different-application-architectures-modeling-and-deployment