首页 > 解决方案 > 将 vue 应用程序部署到 heroku 时出错

问题描述

我有一个使用 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..."); 

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

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

这是heroku日志:

2019-12-13T08:55:49.464914+00:00 heroku[路由器]: 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" dyno= connect= service= status=503 bytes= protocol=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字节=协议=https

那么我能做些什么来解决问题呢?

标签: node.jsvue.jsherokuweb-deployment

解决方案


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

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


推荐阅读