部署React
如何部署react(Create-React-App),Express.js和MySQL?
我尝试在cPanel上部署。我是否必须将其更改为生产模式?如何在Express.js上访问API?我必须在Express.js上创建子域吗?
因为到目前为止我只使用同时和nodemon的库。在React.js上我添加了一个这样的代理:“proxy”:“http:// localhost:5000”,其中localhost:5000有一个来自Express.js的端口
server.js中的Package.json脚本
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently --kill-others \" npm run server\" \"npm run client\""
},
React中的Package.json脚本
"proxy": "http://localhost:5000",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
我的应用:
- 客户端>文件夹反应应用程序> Package.json,Src
- 节点模块>服务器的npm
- 服务器>快速配置,路由,控制器
- .babelrc
- server.js
- 的package.json
你在cPanel上有终端访问权限吗?如果是,那么
- 启动节点服务器(使用PS或Nodemon)
- 如果你的cPanel使用任何类型的服务器(例如
nginx
或Apache webserver
),那么配置服务器文件以重定向到localhost:5050
和*:80
上的*:443
- 配置Express.js以在端口
5050
上提供服务
就是这样。
部署React
如何部署react(Create-React-App),Express.js和MySQL?
我尝试在cPanel上部署。我是否必须将其更改为生产模式?如何在Express.js上访问API?我必须在Express.js上创建子域吗?
因为到目前为止我只使用同时和nodemon的库。在React.js上我添加了一个这样的代理:“proxy”:“http:// localhost:5000”,其中localhost:5000有一个来自Express.js的端口
server.js中的Package.json脚本
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently --kill-others \" npm run server\" \"npm run client\""
},
React中的Package.json脚本
"proxy": "http://localhost:5000",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
我的应用:
- 客户端>文件夹反应应用程序> Package.json,Src
- 节点模块>服务器的npm
- 服务器>快速配置,路由,控制器
- .babelrc
- server.js
- 的package.json
你在cPanel上有终端访问权限吗?如果是,那么
- 启动节点服务器(使用PS或Nodemon)
- 如果你的cPanel使用任何类型的服务器(例如
nginx
或Apache webserver
),那么配置服务器文件以重定向到localhost:5050
和*:80
上的*:443
- 配置Express.js以在端口
5050
上提供服务
就是这样。