本文介绍了将Vue应用程序部署到Heroku时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a vuejs app which set up with vue cli, and i'm trying deploy my app to 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"

    • I remove dist from gitignore,
    • I aded a start point like "start": "node server.js" in package.json
    • 这是我在控制台上看到的内容:

      Here's what i see on console :

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

      Failed to load resource: the server responded with a status of 503 (Service Unavailable) /favicon.ico:1

      以下是heroku日志:

      Here's heroku logs :

      2019-12-13T08:55:49.464914 + 00:00 heroku [router]:at =错误代码= H10 desc =应用程序崩溃"方法= GET路径="/"主机= followgoals.herokuapp.com request_id = 09df33ae-96ab-415a-929b-530fb943318d fwd ="37.130.123.179" dyno = connect = service = status = 503 bytes = protocol = https2019-12-13T08:55:49.828341 + 00:00 heroku [router]:at =错误代码= H10 desc =应用程序崩溃"方法= GET路径="/favicon.ico"主机= followgoals.herokuapp.com request_id = 21de7307-502e-4104-a648-8e6b0832a3fe fwd ="37.130.123.179" dyno = connect = service = status = 503 bytes = protocol = https

      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" dyno= connect= service= status=503 bytes= protocol=https2019-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

      那我该怎么办解决问题?

      So what can i do the fix problem ?

      推荐答案

      我遇到了同样的问题,在本地工作,在heroku上出现503错误,我通过转到数据库云服务(mongodb地图集)进行了修复,并进行了更改我的群集上的白名单设置从家"到任何地方".

      I had the same problem, worked on local, 503 error on heroku, and I fixed it by going to my db cloud service(mongodb atlas), and changed the white list setting on my cluster from "home" to "anywhere".

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

      这篇关于将Vue应用程序部署到Heroku时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 14:46