Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

reactjs - React.JS app on one server and Java API, Ubuntu, Apache Tomcat 9 Web server on second server

I have a react, Java API application on Apache Tomcat 9 server on same server. I want to separate React.JS UI into one server and Java API onto second server. Server OS is Ubuntu 20.

I am facing below challenges, need your help to complete POC project:

How to develop and build and deploy React.JS, NODE.JS app on first server to point to Java API, Apache Tomcat 9 on second server.

Please suggest how to resolve these issues or any article’s to read to resolve the issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So you'll have two servers:

  • first, with FrontEnd, handled by NodeJS (or even Nginx, why not?)
  • second, with BackEnd, handled by Tomcat

Your FE should have a configuration with host of BE. Such a configuration is usually made with environment variables. That will cause a request coming from user's browser to NodeJS, then using environment variable the request will be passed through NodeJS to BE.

Another option, FE may go to BE directly, but that will cause FE and BE worknig on different hosts, so that you'll have to configure CORS on your BE.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...