如何连接两个应用程序React / Node?

阿德里安

目前,我在连接两个应用程序时遇到问题。他们是独立的。我想将它们连接到一个应用程序中。第一个应用程序:这是一个登录/注册表格。它是使用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.

Max R

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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

有人可以了解这两个 Express-React-Node 应用程序之间的区别吗?

如何创建一个连接到 Mongo、Node 的 React Web 应用程序,显示 Streak、Badges 等?

Node应用程序中相同npm软件包的两个版本

我的网站如何知道如何与Node应用程序连接?

通过本地网络在两个 node.js 应用程序之间进行简单通信

如何使Node和React应用程序共享类

如何运行两个React本机应用程序?

我们是否需要两个服务器来在服务器端使用node.js运行ext js应用程序

如何构建Node CLI应用程序

如何分发Node JS应用程序?

如何在一个Nginx配置中设置两个Node.js应用

如何在Node.js Web应用程序中管理MongoDB连接?

如何连接到远程主机上的 node.js(keystone) 应用程序?0.0.0.0:3000

如何将 Vue 应用程序连接到服务器(Node、MongoDB)?

如何将node.js应用程序与python脚本连接?

MongoDB / javascript / node.js / typescript:如何连接到两个猫鼬模型?

在node.js应用程序之间共享MongoDb连接

如何将两个离子应用程序连接在一起?

如何使用socket.io连接两个应用程序

如何在 Flask 应用程序中连接两个用户输入?

如何在Docker中运行两个Node.js应用和mysql

如何在Node.js中设置两个意图不同的工作程序?

如何使用Node JS Express应用程序创建一个喜欢的按钮?

如何在React和Node应用程序中添加加载微调器?(Nodemailer)

使用 node js api 时如何尊重 React js 前端应用程序中的 windows 使用

如何构造/访问非node.js应用程序的react组件?

如何在 gulp/node 中预渲染 React 应用程序?

如何检查React或Node应用程序是否经过OWASP证明?

如何获取chart.js图表以在Node / React Web应用程序中显示数据?