简体   繁体   中英

React app: Using Node/express as middle-end proxy server

I am building a React app for a traditional RESTful API server (Golang). The straight-forward approach is easily:

React --> Redux (or any flux) --> Go server

However I'm now thinking of plugging in Node/express as a middle end, so the stack becomes:

React --> Redux --> Node/express --> Go server

The benefits that I can think of are:

  • Server side rendering
  • Faster form validation
  • Wash the data before sending off to Go API, with numerous amazing node packages
  • Manage authentication and sessions easily

The cons are apparent, with the added layer, any requests that eventually go to back-end will take more time back and forth.

I am pretty new to architecture, would be great to know if people are using this extra stack in their production projects? How is the experience?

We are using a similar stack React --> Redux --> Node/express OR Go server for our application. We sacrificed the additional latency with the proxy node server for the ability to connect with a SSO server (different than our GO server), but also to do server side rendering.

The reason we chose this was because we are a public facing website that allows users to share posts to Facebook. If we didn't have the server side render, we would need to pay for an expensive service like Prerender.io.

The only thing I would propose (which we did) was make SOME calls, like rendering or stuff related to SSO, through the node server, but allow some direct API request go directly to the GO server. Unless you need to do something to each request between GO and React, I recommend this to prevent some overhead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM