目前,我在连接两个应用程序时遇到问题。他们是独立的。我想将它们连接到一个应用程序中。第一个应用程序:这是一个登录/注册表格。它是使用MySQL在Node.js,Express.js,React.js中编写的。文件结构如下:
第二个应用:这是一个to_do_list。它是使用MySQL在Node.js中编写的。文件结构如下:
I would like to run this two application in two ways (make some type of template for future projects) : ad.1 First users register/login (www.example.com/) to application and then there is a redirect to to_do_list application (www.example.com/to_do_list). ad.2 First users see a to_do_list application (www.example.com/) and then if user want to change/ update something in to_do_list, it's require a login in so there is a redirect to login page(www.example.com/login).
I don't know how to proper connect this two applications (mainly how to create a proper files structure). I have two reasons but don't sure that is proper line of thinking. Currently this two applications run on two independent servers (every have own package.json and node start initialization).
For ad.1 : Create directory in Back-end part of register_app and copy all files from to_do_list app. Then install in package.js of register_app all require scripts that to_do_list uses. Finally I should make a proper redirections and dependences for all filles.
For ad.2: Create a folder called to_do_list and copy there all to_do_list app files. Create second folder called register/login and copy there all register/login_app files. Uses some type of proxy to connect this applications (but it is impossible to run two application on the same port so ... ?).
If you have any kind of reason how to in easy way connect this 2 apps I will be so grateful. I am at beggining of my fullstack way.
If you are passing non-sensitive data between the two pages, you could include the data as a query param (see this question)
如果敏感,则应分离后端,并使用一个统一的API,两个应用程序都可以与之交互,并且后端应与之交互。
如果您只想将两个项目合并为一个,则应该很简单,例如移动文件,更新引用以及添加所需的软件包。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句