如何在Heroku上的React Server上登陆客户端App.js

我有一个nodejs客户端和一个react服务器,它们与代理(在package.json中定义)进行通信。在本地计算机上,npm run启动服务器,然后启动客户端,并且可以在浏览器中看到该客户端。 但是,当我使用相同的package.json部署到Heroku并尝试访问客户端登录页面时,我只会看到server.js。

我曾尝试在服务器端和客户端更改package.json中的“脚本”,目前,它们似乎已上传并安装在Heroku上,但是,当我尝试以浏览器,仅访问服务器端。

 package level package.json:
 {
   "name": "xxxxx","version": "1.0.0","description": "App ","main": "App.js","scripts": {
 "client-install": "npm install --prefix client","start": "concurrently \"npm run server\" \"npm run client\"","server": "nodemon server.js","client": "npm start --prefix client","dev": "concurrently \"npm run server\" \"npm run client\"","heroku-postbuild": "npm install --prefix client && npm run build --prefix client"
 },"author": "xxx","license": "ISC","dependencies": {
   "bcryptjs": "^2.4.3",},"devDependencies": {
    "concurrently": "^4.1.1","nodemon": "^1.19.1"
   }
  }

客户端级别package.json

  "name": "client","version": "0.1.0","private": true,"dependencies": {
  "axios": "^0.19.0","moment": "^2.24.0","react": "^16.8.6","react-dom": "^16.8.6","react-moment": "^0.9.2","react-redux": "^7.1.0","react-router-dom": "^5.0.1","react-scripts": "3.0.1","redux": "^4.0.4","redux-devtools-extension": "^2.13.8","redux-thunk": "^2.3.0","uuid": "^3.3.2"
 },"scripts": {
   "start": "PORT=3006 react-scripts start","build": "react-scripts build","test": "react-scripts test --env=jsdom","eject": "react-scripts eject"
  },"eslintConfig": {
    "extends": "react-app"
     },"proxy": "http://localhost:5000"

}

预期结果是在浏览器中看到客户端页面。

实际结果:服务器端注释(API正在运行)。

我想使用URL通过浏览器访问客户端应用程序页面。

charmprefect 回答:如何在Heroku上的React Server上登陆客户端App.js

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3170068.html

大家都在问