【问题标题】:Getting error when i deploy vue app to heroku将 vue 应用程序部署到 heroku 时出错
【发布时间】:2020-04-06 17:12:14
【问题描述】:

我有一个使用 vue cli 设置的 vuejs 应用,我正在尝试将我的应用部署到 heroku。

这是我的服务器:

const express = require('express');
const port = process.env.PORT || 8080;

const app = express();

app.use(express.static(__dirname + "/dist/"));
app.get(/.*/ , function(req,res) {
  res.sendfile(__dirname + "/dist/index.html");
});

app.listen(port);

console.log("Server started..."); 

  • 我从 gitignore 中删除了 dist,
  • 我在 package.json 中添加了一个类似 "start": "node server.js" 的起点

这是我在控制台上看到的:

加载资源失败:服务器响应状态为 503 (Service Unavailable) /favicon.ico:1

这里是heroku日志:

2019-12-13T08:55:49.464914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=followgoals.herokuapp.com request_id= 09df33ae-96ab-415a-929b-530fb943318d fwd="37.130.123.179" 测功机=连接=服务=状态=503字节=协议=https 2019-12-13T08:55:49.828341+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=followgoals.herokuapp.com request_id= 21de7307-502e-4104-a648-8e6b0832a3fe fwd="37.130.123.179" dyno=connect=service=status=503 bytes=protocol=https

那么我该怎么做才能解决问题?

【问题讨论】:

  • 您的快递服务器似乎正在崩溃。它在您的本地机器上运行良好吗?
  • 是的,在本地没有问题。
  • 您是如何部署应用程序的?由于您的server.js 很短,我能想到的唯一可能的问题是(1)未安装节点依赖项(express),或(2)/dist/ 目录或/dist/index.html 不存在。跨度>
  • 实际上我错过了 npm 不会在 dist 文件夹中构建 index.html 文件,而服务器会按照您所说的那样等待,这是问题,但是我在 dist 文件夹中添加了 index.html 文件和插件在,但应用程序仍然无法在本地的 Heroku 上运行。我在 Heroku 遇到了这样的错误:加载资源失败:服务器响应状态为 503(服务不可用)感谢您的帮助。

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


【解决方案1】:

我遇到了同样的问题,在 heroku 上处理本地 503 错误,我通过转到我的数据库云服务(mongodb atlas)来修复它,并将集群上的白名单设置从“家”更改为“任何地方” ”。

https://www.youtube.com/watch?v=leNNivaQbDY&t=31s

【讨论】:

    猜你喜欢
    • 2015-09-22
    • 2017-09-14
    • 2015-12-09
    • 2016-04-08
    • 2019-06-25
    • 2020-04-06
    • 2015-05-09
    • 2018-12-25
    相关资源
    最近更新 更多