Microservices UI Frontend with Java and ReactJS Server Side Rendering

后端 未结 2 1390
悲哀的现实
悲哀的现实 2021-02-09 15:10

My current design is to have clients connect to my (Java) Web API Gateway using a browser, the Web API Gateway will call each (Java) microservice to get their JSON data and retu

2条回答
  •  不知归路
    2021-02-09 15:34

    So, a React component needs two things: the JavaScript source code and the data.

    The JavaScript source code can be provided by a CDN.

    The data must be provided by the Microservices.

    If you don't want server side rendering, then the skeleton index.html file along with the JS files are provided by a CDN.

    If you need server side rendering (for SEO purposes, for example) then the API gateway (or another Web server) will render the components using NodeJS by requesting their source code from the CDN and their data from the microservices then return the full HTML to the browser.

    On the client side, React will continue to load other data from the right microservice as JSON using the API gateway.

提交回复
热议问题