如何在用heroku MERN部署的网页的某些部分上修复空白页?

时间:2020-08-11 04:30:18

标签: node.js heroku deployment web-deployment mern

所以我一直在寻找解决方案,但还没有真正找到类似问题的人,所以这是我的问题。

我有一个与heroku一起部署的基本论坛网站。这是指向它的链接https://bestpressv2.herokuapp.com/

最初加载网站时,它可以工作。转到登录/注册页面的路由很好,我可以对用户进行注册。

但是,一旦用户登录,该网页将变为空白。控制台中没有警告/错误,并且我无法浏览登录/注册页面之外的任何页面,因为它们都是空白。

这是我的代码,用于在heroku上提供静态资产,位于我的server.js文件中。

 if (process.env.NODE_ENV === "production") {
   app.use(express.static("client/build"));

   // I tried using this code gotten from a similar question also, but it just crashed my app on heroku.
   //app.use('/static', express.static(path.join(__dirname, 'client/build')));
 }

这些是我package.json中用于构建网页的脚本。

  "scripts": {
    "start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
    "start:prod": "node server.js",
    "start:dev": "concurrently \"nodemon --ignore 'client/*'\" \"npm run client\"",
    "client": "cd client && npm run start",
    "seed": "node client/scripts/seedDB.js",
    "install": "cd client && npm install",
    "build": "cd client && npm run build",
    "heroku-postbuild": "npm run build"
  },

我还尝试将heroku-postbuild脚本更改为

"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"

这给了我同样的问题。

如果有人需要更多信息澄清我可以提供,但是我不确定我还可以提供什么帮助。

0 个答案:

没有答案
相关问题